![]() ![]() Unless you’re a solo developer working on a side project, it’s probably worth using. Now that you’ve gotten your head around the basics of branch creation, it’s a good time to advocate for using some best practices - generally speaking, you should stick to what’s called “git flow” for managing your repository. Best practices for creating and naming branch Interestingly, that relationship is not established automatically by Git - this is because a local branch can actually be linked to a branch of an entirely different name on the server. The `-set-upstream` flag creates a relationship between the branch on the server, and this branch locally. This command tells the remote server that a new branch has been created locally, so that it can recreate the same branch. Now, if you want to push this newly created branch to your remote server, you’ll have to run another command: This behavior produces the same result as running these two commands in order: Pushing a branch to origin However, when we pass in the “-b” flag, this command will create a branch with that name, and update HEAD to point to that branch. Normally, this command is used to check out branches that already exist. It also switches your current HEAD to that branch, so that if you create a new commit, that commit will store a pointer to the last commit made in the checked out branch. The `checkout` command finds the commit that the branch passed to it is referring to, then updates all of the files on your hard drive (the files in your “working tree”) to match the files stored in that commit. Now that we have a fundamental understanding of how branches and commits are stored and operated on, it’s time to explore the checkout command, which is where the magic in this shortcut happens. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |