Skip to content

Instantly share code, notes, and snippets.

@yunsii
Last active October 18, 2022 06:10
Show Gist options
  • Select an option

  • Save yunsii/28f3270861ef63567f97ca1c685b207d to your computer and use it in GitHub Desktop.

Select an option

Save yunsii/28f3270861ef63567f97ca1c685b207d to your computer and use it in GitHub Desktop.
Git 参考手册

Setting your Git

# Every repository on your computer
$ git config --global user.name "theprimone"

# Single repository
$ git config user.name "theprimone"

# Set the Git editor
$ git config --global core.editor "vim"

trivial messages

  • chore: update trivial types

added 'xxx,xxx' (RSA) to the list of known hosts.

# reference: https://serverfault.com/a/631149
ssh-keyscan -H <host> >> ~/.ssh/known_hosts

http 附加帐号和密码克隆仓库

# reference: https://stackoverflow.com/a/55721882/8335317
# encode: https://user+1:Welcome@1234@actual-git-url-for-the-repo
git clone https://user%2B1:Welcome%401234@actual-git-url-for-the-repo

删除 tag

# reference: https://stackoverflow.com/a/5480292
# local
git tag --delete tagname

# remote
git push --delete origin tagname
git push origin :refs/tags/tagname

删除未被 git 追踪的文件或文件夹

# 删除未被 git 追踪的文件
git clean -f
 
# 删除未被 git 追踪的文件和文件夹
git clean -fd
 
# 算上 .gitignore
git clean -xfd

# 此外,可通过 -n 参数查看会被删除的内容,如
git clean -xfdn

推送已经存在的仓库

git remote add origin git@x.xxx.com:xxx/xxx/xxx.git
git push -u origin master

references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment