2013-10-16 33 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