标签:
作者:zhanhailiang 日期:2015-01-06
查看当前branch列表
[root@~/wade/git/billfeller.github.io]# git branch
gh-pages
* master
新建分支
[root@~/wade/git/billfeller.github.io]# git branch dev
切换分支
[root@~/wade/git/billfeller.github.io]# git checkout dev
Switched to branch ‘dev‘
切换到新建分支
[root@~/wade/git/billfeller.github.io]# git checkout -b dev2
Switched to a new branch ‘dev2‘
将提交的文件的信息添加到索引库中
[root@~/wade/git/billfeller.github.io]# git add test.log
将当前文件中所有修改的文件信息添加到索引库
[root@~/wade/git/billfeller.github.io]# git add .
将依据索引库中的内容来进行文件提交
[root@~/wade/git/billfeller.github.io]# git commit -m ‘test‘
[dev2 ce310ee] test
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.log
查看commit的区别
[root@~/wade/git/billfeller.github.io]# git diff
合并其它分支到当前分支
[root@~/wade/git/billfeller.github.io]# git merge dev2
Updating d509c69..ce310ee
Fast-forward
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.log
将branch push到远程分支
[root@~/wade/git/billfeller.github.io]# git push origin dev2
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 260 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:billfeller/billfeller.github.io.git
* [new branch] dev2 -> dev2
查看远程分支
[root@~/wade/git/billfeller.github.io]# git branch -r
origin/HEAD -> origin/master
origin/dev2
origin/master
查看本地和远程分支
[root@~/wade/git/billfeller.github.io]# git branch -a
dev
* dev2
gh-pages
master
remotes/origin/HEAD -> origin/master
remotes/origin/dev2
remotes/origin/master
修改branch名
[root@~/wade/git/billfeller.github.io]# git branch -m dev mdev
[root@~/wade/git/billfeller.github.io]# git branch -a
* dev2
gh-pages
master
mdev
remotes/origin/HEAD -> origin/master
remotes/origin/dev2
remotes/origin/master
删除远程分支
[root@~/wade/git/billfeller.github.io]# git push origin --delete dev2
To git@github.com:billfeller/billfeller.github.io.git
- [deleted] dev2
[root@~/wade/git/billfeller.github.io]# git branch -a
* dev2
gh-pages
master
mdev
remotes/origin/HEAD -> origin/master
remotes/origin/master
参考文章:
1. Git入门指南十一:Git branch 分支与合并分支
2. Git远程分支和refs文件详解
3. git初体验(三)git分支
标签:
原文地址:http://blog.csdn.net/billfeller/article/details/42466759