git branch分支开发
作者:zhanhailiang 日期:2015-01-06查看当前branch列表[root@~/wade/git/billfeller.github.io]# git branchgh-pages* master新建分支[root@~/wade/git/billfeller.github.io]# git branch
·
作者: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分支
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献2条内容
所有评论(0)