문제

I commit all my stuff to special branches like feature/1234. A feature that we thought it is already done was then merged to master. This feature needs to go back to development again, but there are other commits in master which need to go live now.

How can I get these single commits out of master and still keep them in feature/1234?

EDIT: the commits from feature/1234 are not the latest ones.

도움이 되었습니까?

해결책

Edit after understanding the problem

git rebase is your friend. Just run git rebase -i commit-id where commit-id is the one previous to the three you want to remove, then, when the default editor will open, simply delete the three commits you do not want on master, save and close.

Old version, misunderstood
If I understood, you should have no problem with your second request: the commit is still in feature/1234 if you have not deleted the branch.
As for the first request, remove the commit, just run git reset --hard HEAD~1 which will move the HEAD back one commit.
If you want to go back to a specific commit by its id, you can run git reset --hard commit-id.
For more info about reset: http://git-scm.com/blog/2011/07/11/reset.html and https://www.kernel.org/pub/software/scm/git/docs/git-reset.html

다른 팁

If you can rebase your branch, then that's sometimes the cleanest way of removing acommit - all traces of it will be gone. The disadvantage is that any branch taken from your master branch between the time the offending commit got in and the time when you remove the commit will have histories that have diverged with the master. If you can't guarantee that this has not happened (e.g. if you have published your repo to others), then it's probably bette to revert the commit using git revert. That wil produce a new commit on top of your master which undoes the changes of the old one. History thus keeps going forward, and sub-branches can simply rebase to the lastest as usual.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top