![]() This could tell you the branch does not exist. ![]() 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. git checkout -b feature/JIRA_ISSUE_NUMBER-update-layout-for-this-page.So let's say that you are on develop branch and you have done the above by checking out the branch and have fetched and pulled the latest you would then create a branch off of that main branch using standard git checkout -b my-feature-branch That being said, you should always create branches and never push directly to your develop or master branches. Yes this does seem like duplicate work but working with Bitbucket I will say that this is the safest and sanest way to ensure that you have the latest from the branch that you are working on. fetch all branches and latest changes as well as pull in all changes from the branch you are on. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |