Created
April 11, 2020 09:38
-
-
Save doKill/75756e5d1eb5fad8b91d069617db511e to your computer and use it in GitHub Desktop.
null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
一键拉取本地上不存在的远程分支 | |
git checkout br | |
git pull | |
``` | |
``` | |
查看本地以及远程分支 | |
git branch -a | |
``` | |
``` | |
删除远程分支 | |
git push origin :br (origin 后面有空格) | |
``` | |
``` | |
查看标签 | |
git tag | |
打标签 | |
git tag -a v1.1 -m 'my version 1.1' | |
推送本地tag到远端 | |
git push origin v1.1 | |
删除本地tag | |
git tag -d v1.1 | |
删除远端tag | |
git push origin :refs/tags/v1.1 | |
``` | |
``` | |
删除远程仓库中的提交版本 | |
git reset --hard 版本号 | |
git push origin master -f | |
``` | |
``` | |
如何修改之前的 commit 信息 | |
其实并不复杂,我们只需要这样做: | |
1、将当前分支无关的工作状态进行暂存 | |
git stash | |
2、将 HEAD 移动到需要修改的 commit 上 | |
git rebase 9633cf0919^ --interactive | |
3、找到需要修改的 commit ,将首行的 pick 改成 edit | |
4、开始着手解决你的 bug | |
5、git add 将改动文件添加到暂存 | |
6、git commit –amend 追加改动到提交 | |
7、git rebase –continue 移动 HEAD 回最新的 commit | |
8、恢复之前的工作状态 | |
git stash pop | |
``` | |
``` | |
本地拉取远端git pull出错 | |
> Pull is not possible because you have unmerged files. | |
Please, fix them up in the work tree, and then use 'git add/rm <file>' | |
as appropriate to mark resolution, or use 'git commit -a' | |
如果想放弃本地的文件修改,可以使用git reset --hard FETCH_HEAD,FETCH_HEAD表示上一次成功git pull之后形成的commit点。然后git pull就OK了。 | |
``` | |
``` | |
.gitconfig配置 | |
[alias] | |
co = checkout | |
ci = commit | |
ac = commit -am # 相当于 git add 和 git commit -m | |
ci0 = commit -a --allow-empty-message -m '' # 无备注提交 | |
st = status | |
br = branch | |
pl = log --pretty=oneline | |
rpl = reflog --pretty=oneline | |
gpl = log --graph --abbrev-commit --decorate --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(dim white) - %an%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)' | |
back = reset --hard | |
search = grep -n # 搜索仓库文件内容或提交日志中匹配的信息 | |
configg = config --global -l #查看全局级的 config | |
configl = config --local -l #查看仓库级的 config | |
configs = config --system -l #查看系统级的 config | |
[user] | |
name = * | |
email = * | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment