Of course, if your branch already exists in the remote location, you can just run git push. Referencing HEAD saves you from having to type out the exact name of the branch. When you come to push your changes to that remote location you can't just use the git push command you need to use a slightly different command, either of these: git push -u origin branchname When you create a branch on your local copy of the repository it won't automatically create within the remote location. If you have cloned a Git repository from a remote location and it's come with a bunch of branches, then you can use the following command: git checkout -track origin/branchname Switch to a branch that's came from a remote repo If you have a branch within your local repository that you've created then you can easily switch to it using the following command: git checkout branchname When you are working within a repository, and you want to check what branch you are on you can use the following command: git status You can now start to work on your changes and commit them there. Do create a new branch you can run the command: git checkout -b newbranchname If you have a copy of a repository and you want to make changes then creating a new branch is best practice. There are a few commands that you can use to work with branches, let's take a look at them. You might create a new branch when you want to work on a new feature, or bug fix and keep those changes completely separate until you are ready to release them. Effectively they are a point to your changes. What are Git branches?īranches are an everyday part of the process when using Git. Today I am going to dive into what branches are and how they can be used. So far on my learning journey has taken me on the following path: It is Day 9 of my learning journey into Git.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |