I have a typical problem which is like the following:
1) I was working on an Issue X, I made 2 commits for that issue, but I was stuck in between and did not push the changes to my remote repo.
My git status on master branch says that
Your branch is ahead by 2 commits.
2) I am now assigned a new task and I want to push the 2 commits which I did in the master branch in a local branch which I would create now.
I tried achieving the same as :
1) git log (on master and noted the commit nos lets call them 1111(for commit 1, old commit) and 2222(for commit 2, newest commit)
2) git checkout -b my_local_branch
3) git cherry-pick 1111
Now, there are conflicts. Can someone tell me what is it that I should do. Maybe apply the newest commit because I feel that my local branch does not have those commits (I might be wrong), because when I do
git status (on my local_branch), I don’t see that my branch is ahead of any commit.
Thanks
I guess this will work.
On your master branch, run
git branch -b my-local. Check that your commit 1111 and 2222 are O.K.Go back to master branch:
git checkout master.Run
git rebase -i, and delete commit 1111 and 2222.Now master branch got rid of 1111 and 2222, you can start your new task. (And commmit 1111 and 2222 are in your my-local branch.)