

Git checkout = without bothering to find out what the state of a repository is, try to switch to a branch. Git fetch & git checkout = first find out what the state of the repository is. With all that in mind, going back to the original question If you do not do this then next time you try to commit changes you will accidentally break stuff.Īlthough if it is the very first time you ever checkout a branch on the current machine you do not need to use this command. This actually updates your currently worked on branch (see step 2) to match the online repository. This just switches your git to work on that branch. Thus tricking you into thinking you do not need to do step 3 Or switch to an outdated version of it and falsely inform you that you are up to date with the online repository when in fact you are not. It generally should be done before any operation and many people run scripts that aggressively do this automatically every minute.įor example, if you just try to go to step 2 without doing fetch all first, then it could very well return an error that said branch does not actually exist. This command makes git find out the state of the online repository actually is. It is a good idea to get into a habit of always doing fetch -all

If you just do the 2 steps described in your OP then you are in for some pain.įor a simple explanation with minimal jargon, if you want to locally work on a branch called devA the 3 steps are:Īlthough you could technically fetch just this one branch. You actually need 3 steps to properly switch your working branch. Now you have checked out the develop branch, pulled down all the latest changes and remote branches and created a feature branch from that develop branch.

create a branch, then you should be ok using the commands that they have provided as you pasted in your example. To chime in here since I have to use Bitbucket daily for multiple projects and multiple branches I will give you my recommendation.
