By
coney
更新日期:
git 分支
github 分支的相关指令
1 2 3 4 5 6 7
| git branch git branch -r git branch -a git branch <文件名> git branch -m oldbranch newbranch git branch -d branchname git branch -d -r branchname
|
github 分支的切换
1 2
| git checkout branchname git checkout -b newbranch
|
搞定。
github 分支的合并
1 2 3 4
| git merge branchname e.g. git merge aa git merge branchname1 branchname2 e.g. git merge aa bb
|
忽略某些文件的合并
1 2 3 4 5 6
| git checkout aa #切换到分支aa vim .gitattributes #创建.gitattributes文件并用vim打开 config.yml merge=ours. #将前面这句话写入.gitattributes :wq #在vim的命令行下敲入:wq, 保存并退出vim. git add .gitattributes #add 该文件 git commit -m "your commit" #commit 该文件
|
config.yml merge=ours
这句话的意思是当合并时,如果与其他分支的config.yml文件发
生冲突,取消合并,使用当前分支下的config.yml文件.
然后切换到另一个想要合并的分支B中重复刚才的操作。
最后
大功告成!
合并指定文件
1 2
| git checkout branchname -- file1 file2 etc e.g. git checkout aa -- file1 file2
|