您的位置:首页 > 其它

git 命令总结 (持续更新)

2014-10-09 10:28 337 查看
1. 删除分支

1.1 本地分支

git branch -d iss53


1.2 远程分支

git push origin :iss53


2. 已经暂存起来的文件和上次提交时的快照之间的差异

git diff —staged


3. 比较2个不同版本之间的差异

git diff [branch]:[filename] [other-branch]:filename


4. 打tag

git tag -a v1.1.0 -m  "fix bug” [branch]
git tag v1.1.0 master  # 也可以简单点写
git push --tags


4.1 获取仓库中的所有tags

git fetch --tags


4.2 删除本地tag

git tag -d v1.0.0
4.3 删除仓库中的tag

git push origin :refs/tags/v1.0.0


5. 显示当前版本

git show master
git show develop
git show origin iss53
git show v1.0.35


6. 撤销上一次提交

git revert HEAD


7. 显示远程仓库的详细信息

git remote show origin


8. clone 出分支

git clone git@github.com:vearne/carspider.git


clone 出非master的其它分支

git checkout -b develop origin/develop


在本地创建一个 develop 分支,并把它和 origin上的develop 分支关联起来

9. 放弃所有本地变更

git checkout -f


10. 设置upstream

git branch --set-upstream my_branch origin/my_branch


参考资料: http://gitbook.liuhui998.com/4_9.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: