In this post, we'll be using the jgit repository as our server repository, but we have to make a clone of it to a bare repository so we can push it. You can't push to the checked-out branch on a non-bare repository, as this can overwrite the work area and index.
Step 1 : Create a bare repository from the jgit repository and create a new Git repository
Step 2 : We also need to change the branch names on some of the branches to match the example for namespacing;
Step 3 : Let's set up our new repository to only fetch the master branch. We do this by changing the fetch line under [remote "origin"] in the configuration file (.git/config), as follows:
Step 4 : Now, we will only fetch the master branch and not all the other branches when executing a git fetch, git pull, or a git remote update origin, as follows:
Step 5 : Let's also set up a separate refspec to fetch all the stable* branches to the local repository as follows:
Step 6 : Now, fetch the branches locally, as shown in the following command:
Step 7 : We can also set up a push refspec that specifies where branches are pushed to by default. Let's create a branch called develop and create one commit, as shown in the following commands:
Step 8 : Now, let's create a push refspec that will send the content of the develop branch to integration/master on origin:
Step 9 : Let's push our commit on develop as follows:
As the integration/master branch didn't exist on the remote side, it was created for us.