# git常用命令
# config配置
# 配置列表
$ git config --list
credential.helper=osxkeychain
user.name=LarryDpk
user.email=larry@xxx.com
# 设置某个属性
$ git config [--global] user.name "LarryDpk"
$ git config [--global] user.email "larry@xxx.com"
# Branch分支
# 列出本地分支
$ git branch
* main
# 列出本地和远程所有分支
$ git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/main
# 列出远程的分支
$ git branch -r
origin/HEAD -> origin/main
origin/main
# 新建分支
$ git branch develop
# 新建分支并切换
$ git checkout -b develop
# 删除分支
$ git branch -d develop
# 删除远程分支
$ git push origin --delete develop
# tag操作
创建tag:
$ git tag v1.0.1 main
列出tag:
$ git tag
v1.0.0
v1.0.1
推送tag到远程:
$ git push origin v1.0.0
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:LarryDpk/xxx.git
* [new tag] v1.0.0 -> v1.0.0
删除本地的tag:
$ git tag -d v1.0.0
Deleted tag 'v1.0.0' (was a600b18)
删除远程tag:
$ git push --delete origin v1.0.0
To github.com:LarryDpk/xxx.git
- [deleted] v1.0.0
# cherry-pick相关
cherry-pick后不提交:
git cherry-pick -n <HASH>
# 其它
修改上次commit的时间:
git commit --amend --date="Thu May 18 02:00 2023" --no-edit
References:
- https://stackoverflow.com/questions/5195859/how-do-you-push-a-tag-to-a-remote-repository-using-git
- https://devconnected.com/how-to-delete-local-and-remote-tags-on-git/
- https://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html