I've made a branch on one machine (call it the 1st machine) and then pushed my commits to the online server. Then I performed a `pull` request from a 2nd machine. On the 2nd machine I only had one master branch. I got that all the changes in my new branch are merged into my master branch. I did not expect this. I wanted to have the new branch on the 2nd machine as well.
I now see that I should have done "fetch" instead of "pull". The question is, how do I invert this pull request?
BTW, I saw the answer here, but I don't see a `Reset...` option when clicking on the last commit of master.
You have to click on the commit you want to reset to, then you should see the option. You can also reset from the command line by using git reset --hard <commit to reset to>, or if you have not pushed your changes back to the remote master, you can use git reset --hard origin/master
In order to see new branches created on the remote you need to do a fetch in order to update your local repository. Doing a pull will not fetch any new branches, it will only fetch changes made on your current branch and then merge it.
@Mikael Sandberg Thanks. Do I need to choose the "hard" option when choosing to reset? It will not delete what I have on the server, right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hard will reset the index and working tree, meaning if you have made any local changes on master that has not been pushed to your remote, those will be deleted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mikael Sandberg I did this, and indeed it works. In the history view I still see the latest commit I did by mistake, but the files are reverted.
Now, I did fetch, but I don't see the new branch in my 2nd machine. Why is that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you check under Remotes > Origin?
You can also run git branch -r to list all the remote branches that your local repository knows about.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right-click on it and select Checkout origin/..., that will bring up the checkout branch screen and from there you just select OK and it will create a local copy of the branch and setup the link to the remote branch.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.