How to create an empty branch for documentation

We have several Linux servers in the office. I would like to keep some record of changes in settings. Therefore I thought it would be a good idea to put all configuration files in GIT.

The setup I would like to have is as follows:
bare repository –> configuration.git
with a branch for every server in which we put the directory structure and the configuration files.

I can’t find how to do this. Somewhere I read something with –orphan but somehow I ended up with and master and MASTER branch and no empty branch for my configuration files.
I want an empty branch with no history and no link to the master.

Can anybody point me in the right direction?

  • git mess -overwrite master with branch?
  • List merged and unmerged git branches by time
  • Is it possible to have git automate resolution of a certain kinds of merge conflicts
  • Why “git checkout master” didn't revert file content back to previously?
  • Create private branch on remote repository in git
  • Git create branch from current checked out master?
  • What's the best way to manage parallel versions in Git?
  • how to get all branches of my forked git repo
  • 3 Solutions collect form web for “How to create an empty branch for documentation”

    Keep in mind an important passage from the documentation on git checkout --orphan:

    If you want to start a disconnected history that records a set of paths that is totally different from the one of , then you should clear the index and the working tree right after creating the orphan branch by running git rm -rf . from the top level of the working tree. Afterwards you will be ready to prepare your new files, repopulating the working tree, by copying them from elsewhere, extracting a tarball, etc.

    To start a new branch for server1, run

    git checkout --orphan server1
    git rm -rf .
    

    From there, add and commit as usual, e.g.,

    touch foo.conf
    git add foo.conf
    git commit -m 'Create foo.conf'
    

    You have to do the following:

    1. Create your configuration repository
    2. For server server01create the branch server01:

      git symbolic-ref HEAD refs/heads/server01
      rm -f .git/index
      git clean -fdx

    3. IMPORTANT: You must now add and commit something to this branch.

    4. Repeat with 2. for the next server.

    Afterwards you can simply do a git checkout serverXX to change the branche.

    If you didn’t have an initial commit in the master branch then you will not have a master branch after this procedure. (But you can just do what was described in 2. for the master branch.)

    You can check the result with

    git log --graph --branches --decorate

    It should look like this:

    * commit: .... (server01)
      Author: Max Muster <max.muster@example.com>
      Date: Mon Feb 2 16:00:00 2015 +0100
    
        First commit of server01 branch
    
    * commit: .... (server02)
      Author: Max Muster <max.muster@example.com>
      Date: Mon Feb 2 16:01:00 2015 +0100
    
        First commit of server02 branch
    
    * commit: .... (server03)
      Author: Max Muster <max.muster@example.com>
      Date: Mon Feb 2 16:03:00 2015 +0100
    
        First commit of server03 branch
    
     [...]
    
    * commit: .... (HEAD, server99)
      Author: Max Muster <max.muster@example.com>
      Date: Mon Feb 2 17:00:00 2015 +0100
    
        First commit of server99 branch
    

    If Git is telling you that you are still in the master branch, then it likely means that not only are you in the wrong branch, you are in the wrong repository. If I read your description correctly, you want a separate repo (and branch) for your server configuration files. Try the following steps:

    1. Change to the root directory containing your configuration files. Make sure that this directory is not contained within the repo of your master branch or any other already-existing git repo.
    2. Type git init. This initializes your directory to be a Git repository
    3. Type git add ... This adds all the configuration files in your directory to be tracked by Git. If you only want certain files you can add them with git add [filename].
    4. You are now ready to start using Git. The default branch is master, but you can create any branch you want, and commit your changes.
    Git Baby is a git and github fan, let's start git clone.