git re-committing reverted commits
I have a project hosted on github. There is a main branch (main-branch) for the code that is deployed in production. Individual projects are branched from main (proj-001, proj-002...).
So in the course of a project/deploy....
- git checkout main-branch
- git pull origin main-branc开发者_StackOverflow社区h
- git checkout -b proj-001
- (make some edits)
- git add .
- git commit -a -m "some notes"
- (merge the main-branch into my working branch)
- (make some more edits)
- git add .
- git commit -a -m "some more notes"
at some point the librarian pulls all of the code together for a test/deploy cycle. If there is a problem with a particular branch it is reverted. (and the bad news is that once it is reverted getting that branch back into the main-branch is difficult and risky.)
So my QUESTION: what is the best and easiest way to pull my commits into a new branch? (my current attempt to "cherry-pick" resulted in an error "fatal: Your index file is unmerged." which Google failed to describe.
UPDATE: I've updated the events... the librarian inadvertently merged the main-branch into my working branch... on more than one occasion.
I really wish someone else would have answered this question... but in the meantime since I have an answer and it seems to be working... I might as well share.
The big issue is that others merged the main branch back into my branch. That made any sort of cherry picking or apply difficult. Also, it was a challenge to find the right command that would give me a comprehensive list of changes that I made. So the basic outline:
- checkout my project
- git checkout
- get a list of my changes
- git log --pretty=oneline --committer= >/tmp/changeset.txt
- edit the file and remove the descriptions, prefix each line with 'git merge'
- reverse the order
- tail -r /tmp/changeset.txt
- then merge them one at a time and resolve any conflicts as they occur.
精彩评论