使用git进行系统开发时,刚开始采用主干master,在项目更新频繁的状况下,就须要新建分支进行开发,每次将新的分支branch提交到gitee上,开发完毕时新分支合并到主干master上。git
从已有的分支建立新的分支(如从master分支),建立一个test分支git branch test
建立新分支git checkout test
切换到新分支
上面命令等用于git checkout -b testspa
git branch
*表示在当前分支git push origin test
git pull origin test
git branch --set-upstream-to=origin/test
git branch --unset-upstream master
在分支test上开发完成后,须要合并到主干master.net
git checkout master
git push origin
再次上传git push --set-upstream origin master
报错以下:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/tahara/blue...'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
出现这个问题是由于gitee中的一些文件不在本地代码目录中,能够经过以下命令进行代码合并code
git pull --rebase origin master
blog
git branch -d test
git branch -D test
删除git push origin --delete test