Git 常用命令
push tag:
- git push \<remote> tag_name # push a single tag
- git push \<origin> --tags # push all tags
undo all uncommit changes:
- git clean -fd # delete all untracked files and directories
- git reset --hard # removes staged and working directory changes
- git checkout /path/to/your/file # checkout a file from HEAD, and overwrite your change.
pring branch tree
在.gitconfig
中添加:
1 | [alias] |
使用命令git lg
就可以在命令行中看到branch tree 了
Reference:
回滚到指定 commit id
1 |
|
Reference
- https://stackoverflow.com/a/1895095/5432806
- http://serebrov.github.io/html/2014-01-04-git-revert-multiple-recent-comments.html
- https://stackoverflow.com/a/4114122/5432806
save HTTPS account
- (Recommended) attach credential to remote repository url:
https://username:password@git.coding.net/username/repository.git
- store temporarily: execute command
git config credential.helper 'cache --timeout=60'
, then credential will expire after 60 seconds since last use. - store permanently: execute command
git config --global credential.helper store
, then credential will be stored in file~/.git-credentials
and~/.gitconfig
permanently.
Reference: