我在github上有一个私有项目.我有一个该项目的生产分支.我有一台新机器,我需要在生产上修理一些东西.这就是我做的.
git clone git@github.com:userid/project.git
# now I have master branch
git co -b production
git pull origin production
Run Code Online (Sandbox Code Playgroud)
使用上面的机制,我能够获得生产分支,但我得到合并冲突,我现在不想处理.
是否有一种更清晰的方式来获取我的本地机器上的生产分支代码?
Von*_*onC 18
您可以在获取后直接签出远程分支
git fetch origin
git branch -f remote_branch_name origin/remote_branch_name
git checkout remote_branch name
Run Code Online (Sandbox Code Playgroud)
或更短:
git checkout -b production origin/production
Run Code Online (Sandbox Code Playgroud)
您将直接使用获取的原始/生产分支副本(没有冲突).
通过做
git co -b production
git pull origin production
Run Code Online (Sandbox Code Playgroud)
您正在尝试将远程生产分支合并到主服务器中(在本地"生产"分支中,如果您的主服务器本地具有与远程源/生产分支不同的历史记录,则意味着可能会发生冲突.
git checkout -b production
单独检查一个新的分支production
,该分支基于您当前已检出的分支,即主分支.
你真正想做的事情很可能是:
git checkout -b production origin/production
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16064 次 |
最近记录: |