美文网首页
Git Learn II

Git Learn II

作者: 无为真君 | 来源:发表于2018-12-07 12:54 被阅读0次

查看分支

$ git branch

创建+切换分支.

$ git checkout -b <name>

创建分支

$ git brance <name>

切换分支

$ git checkout <name>

合并指定分支到当前分支.

$ git merge <name>

删除分支

$ git branch -d <name>

查看分支图

$ git log --graph

储藏当前工作现场

$ git stash

查看储藏列表

$ git stash list

恢复现场,stash内容不删除

$ git stash apply

删除stash内容.

$ git stash drop

恢复现场,同时删除stash内容.

$ git stash pop

恢复指定现场

$ git stash apply stash@{0}

如果要丢弃一个没有被合并过的分支,可以通过下面命令强行删除.

$ git branch -D <name>

查看远程库的信息

$ git remote

查看远程库的详细信息

$ git remote -v

从本地推送分支,使用

$ git push origin branch-name

如果推送失败,先用git pull抓取远程的新提交

$ git pull

在本地创建和远程分支对应的分支,使用

$ git checkout -b branch-name origin/branch-name

建立本地分支和远程分支的关联

$ git branch --set-upstream branch-name origin/branch-name

从远程获取最新版本到本地,不会自动merge

$ git fetch orgin master

从远程获取最新版本并merge到本地

$ git pull orgin master

新建一个标签,默认为HEAD也可以指定一commit id

$ git tag <name>

指定标签信息

$ git tag -a <tagname> -m "blablabla..."

可以用PGP签名标签

$ git tag -s <tagname> -m "blablabla..."

查看所有标签

$ git tag

查看标签信息

$ git show <tagname>

推送一个本地标签

$ git push origin <tagname>

推送全部未推送过的本地标签

$ git push origin --tags

删除一个本地标签

$ git tag -d <tagname>

删除一个远程标签

$ git push origin :refs/tags/<tagname>

相关文章

网友评论

      本文标题:Git Learn II

      本文链接:https://www.haomeiwen.com/subject/uclthqtx.html