Git Pull Origin Overwrites Master?
I Have a Repository on Github, Aav1 on My Laptop I Have Two Branches, One Called Master and One Called Vs12Up the Master Branch Was When the Software Was...
I have a repository on Github, aav1
On my laptop I have two branches, one called master and one called vs12up The master branch was when the software was Visual Studio 2008, vs12up is converted to Visual Studio 2012.
On my laptop everything seems fine and I pushed the new branch to github, appears correct.
On my desktop I tried to pull the remote branch:
git pull origin vs12up
It wrote the changes to my master branch on the desktop, git log shows the commits made on the vs12up branch, but git branch only shows master, which is the current branch.
How can I revert the changes to the master branch and pull the vs12up branch on my desktop to match the repository on my laptop?
1 Answer
If you do a git pull with a remote branch name, it will fetch the remote branch and then merge it into your current local branch. So to undo that, you will first have to reset your local branch to the remote master, then create a new local vs12up branch from the corresponding remote branch.
Reset your local
masterto match the remote repository'smaster(WARNING: be sure that you don't have any uncommitted changes you want to keep before issuing the following command):git reset --hard origin/masterFetch all remote branches into your local repository:
git fetch originCreate a new local
vsup12branch from the remotevsup12branch, and switch to this new local branch:git checkout -b vsup12 origin/vsup12
Note that when you subsequently just do a git pull while switched to the vsup12 branch, you'll fetch and merge the latest changes from the vsup12 branch on Github into your local vsup12