Search code examples
gitvisual-studiogit-mergegit-branch

What do I do with local commits for a remote branch that has been merged?


I use Visual Studio on Mac and PC working on the same project.

I had a branch called "fixbug" and did work on both machines on it. I thought that I had pushed all my changes so on my PC I merged the branch into master and deleted it. Since then I have done a bunch of work on my PC in another branch but then came to realize some changes were missing. It turns out they are on the mac side and were locally committed to the "fixbug" branch but never pushed to remote.

I don't know the git commandline well, I use the IDE tools.

What is they best way for me to get these changes back into master and then the current development branch that I have going? Do I merge them with master locally on Mac, then push to remote, then on my PC pull changes from master to my dev branch? If so can someone walk me through the commands to make this happen?

Thanks.


Solution

  • These are the steps you have asked for. I shall write detailed command descriptions so that, if this is not that you want, you will not lose your work.

    // from your Mac fixbug local branch   
    git pull origin master // pulls current master branch to your local PC fixbug branch
    git push origin fixbug // pushing your local fixbug branch to remote fixbug branch. 
    git checkout master // moving to the branch master
    git pull origin fixbug // pulling the remote fixbug branch which contains the missed work
    git push origin master // pushing local master to remote git.
    
    //from your PC dev branch
    git pull origin master // from your current new working branch, pull the updated master
    

    This for some steps may create conflicts, you can fix those conflicts and move on. Please recheck if this is what you want.