English 中文(简体)
如何将变化从一个分支转移到另一个分支部门。
原标题:How to move the changes from one branch to another branch git?
  • 时间:2011-11-10 20:28:02
  •  标签:
  • git

How can I move my work and changes from the master branch to a newly created branch and leave the master branch intact after the move?

最佳回答

您可设立一个新的部门,负责 现行<><>>。 采用<代码>git分行名称(或giteckout-b Branchname,如果你希望直接核对的话。 这基本上将重复你的主司,以便你能够继续在那里工作。

如果你成功地复制了该分行,请将<代码>master/code>重新编号至原点,为此请使用<代码>git reset-hard Rat/code>,其中commit是该承诺的背后,该承诺应为最后一项。

例如,你的情况类似:

---- 1 ---- 2 ---- 3 ---- 4 ---- 5 ---- 6
                   ^                    ^
              original                master
            master commit

因此,你在<代码>6上核对了master/code>,并且希望创建一个新的分支>.ticket,指6。 在重新制定<代码>master/code>至3时:

git branch ticket
git reset --hard 3
git checkout ticket

然后,请在<代码>>tket上注明承诺6,而master/code>各点至3

问题回答

www.un.org/Depts/DGACM/index_spanish.htm 如果这些改动没有兑现,

您可以阻止总务部门的变动。

git stash

then checkout the branch

git checkout -b newbranchname

并波及这里的变化

git stash pop

www.un.org/Depts/DGACM/index_spanish.htm 如果做出改动:

之后设立分支机构:

git checkout -b newbranch

返回总务部门:

git checkout master

2. 重启以前的承诺:

git reset --hard head^1

<>PS>/strong>: 只有在没有建立新的档案和仅仅修改现有档案的情况下,才会这样做。

If you have commit (say) 2 times after you realised you should have been in a branch then simply do

git branch work_branch
git reset --hard HEAD~2

用你想要去做的承诺数目取代2。 如果你想前往该处继续工作,那么你现在仍然会领头。

http://code>git rev-parse -help 如果您想了解如何用HEAD~2等参考资料背弃您的树木的辛金。

我以以下方式解决这个问题:

<>Step 1: 建立受感染的<代码>master分行的新分行,并将其命名为master_感染者/代码>;

<<>Step2: 现在hard reset<>/code> http://www.ohchr.org。 页: 1

 git reset --hard HEAD~2  
    

<>HEAD之前的(接下2个<编码>commits,因为就我的情况而言,我有两个被污染的commits。 您的情况可能有所不同。

现在,我的<代码>master_ Affect 分支载有我想要保存的(正如我所说的受污染的代码)和master/code>。 分支机构现在处于一种储蓄模式。

创立一个“新分支”,由您负责,然后将错误的分支改为新的分支机构。

然后,你可以删除bad<>>>> /strong>分行,假定你在别处推动该分行,并对它作出其他改动。

git add --all
git commit -m <commit-message>
git branch -m master <feature-branch-name>
git push --set-upstream origin <feature-branch-name>




相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...