Suppose you just have your local Git repository, and, at the moment, you have no intention of sharing the code with others; you can, however, easily share the knowledge you have while working with a repository with one or more remotes. Local branches with no remotes work exactly in this fashion. As you can see in the examples, we are cloning a repository, and thus we have a remote.
Let's start by creating a few local branches.
Use the following command to clone the jgit
repository to match:
$ git clone https://git.eclipse.org/r/jgit/jgit
$ cd jgit
Perform the following steps to manage your local branches:
- Whenever you start working on a bug fix or a new feature in your project, you should create a branch. You can do so using the following code:
$ git branch newBugFix
$ git branch
* master
newBugFix
- The
newBugFix
branch points to the currentHEAD
you were on at the time of the creation. You can see theHEAD
withgit log -1
:
$ git log...