

- #Update your master git pull origin master update#
- #Update your master git pull origin master Patch#
- #Update your master git pull origin master code#
You’ll also need a git command line tool.

In this post, I’ll assume you are using master. Some development workflows will use a different branch than master for day-to-day development but the same steps apply using whatever that branch name is.

#Update your master git pull origin master code#
The first thing I need to do is to catch up my git repository to whatever the current code is in the master branch of the original repository.
#Update your master git pull origin master Patch#
If I do not, the project I want to contribute to might not be able to apply my patch or merge my pull request cleanly. I have a patch to contribute, or a bug to fix but I want to make sure that my local copy of the repository is not stale. Or, if you are feeling frisky, you can try git pull origin matser – pull changes from server origin, branch master on that server, and then merge those changes into my current branch.Here I am in one of my forked git repositories on GitHub.
#Update your master git pull origin master update#
So if you want to update your branch with latest-freshest master copy – do git pull and git merge origin/master afterward. You can merge all you want – code will still be in the state it was. In graphics above you can see how it flows – unless you do git fetch (or git pull which fetches underneath) – you won’t get server status update. Just keep in mind that when you are doing git merge origin/master – you are checking and merging your local version of branch, last state you have seen on server, not what is there now. You can work offline with your branches, not requiring asking server over and over again what’s going on there. In a few minutes your collegue may add something to master branch and whoops! you’re out of date. So now you have your latest version of code, you are at the same place where origin server is. But your nasty_bug_solution branch will stay unchanged – unless you will merge changes (or you are doing pull which merges changes automatically). Just those that are reflection of server state, like origin/master, origin/nasty_bug_solution, origin/new_fancy_feature etc. Then your local copy of repository gets latest code changes, updates your branch pointers etc. You contact server sometime, usually when you are doing operations like pull, push, fetch. It is latest code since the last time you contacted origin server. “But I am calling origin/master, so I am getting latest, freshest code, right?”. Now that’s perfectly fine, I said, but you are not getting latest changes that were made by others in our team. What my collegue was doing was: git merge origin/master. But he insisted that he in fact did merged master branch changes. We thought it may have been related to latest changes on master branch, that were not included into his branch.

One of those concepts I think is – what is origin/master? How does it differ from master?Ĭollegue of mine had a problem where he could not reproduce issue with code. It does not matter if you are using GitHub, BitBucket, Gitlab – figuring out how it works (at more than basic commit/push/pull level) will be very useful when you will try to set up your workflow or when you find yourself in a corner. When using git, there are few concepts that are hard to grasp at first, but are (in my opinion) required to get fluent with it.
