2013-10-16 36 views
0

当我在项目中的D点时,我对项目进行了一些更改,并将多次提交(E,F,G,H)提交给git,所以我在点。
现在我必须做出新的改变(我),并推动他们git和部署,但我不希望我的老提交(E,F,G,H)部署。
我想回去d做我的变化(我)又不失我的老提交(E,F,G,H)部署它然后继续从点H. 我的项目工作的我只有一个分支MASTERgit结帐并在推送更改后返回上一次提交

我知道我可以做一个git结帐H后退到点H.
我知道这是一个藏匿处为时已晚,因为变化已经COMMITED(E,F,G,H)......

Ie

A - B - C - D - E - F - G - H 
      \   /
       I ----------  

是否有可能?

回答

3
git checkout [sha for d] -b [branch name] 
[make your changes] 
[git add your changes] 
[git commit] 
[push branch] 
[deploy the branch] 
git checkout - # checks out back to the last checkout ref 
1

假设所有提交A到H存在,你是在H点(即主的负责人,因为你的国家,你只有一个分支),你可以尝试:

git reset --hard HEAD~4   // Rolls you back to working state of D 
git checkout -b branch_for_i  // Digress work from D on a new branch 

** Make necessary changes for I 

git commit      // Commits changes required for I 
git push origin branch_for_i  // Pushes up changes done for I 
git checkout master    // Back to the branch with H as HEAD 
git reset --hard HEAD    // Puts you back into the working state at H