client setup

cd git_repo/
git config
git config "your name or user@hostname"
git config
git config "your@email"
git config --global push.default simple
#git config --global core.editor elvis


alternate way,

git config --global --edit
#git commit --amend --reset-author

for docs, scripts & configs you do not want to track like hell, those are some handy GIT aliases,

git config --global 'commit -a --allow-empty-message -m ""'
git config --global 'commit --allow-empty-message -m ""'

to push the devil even harder, one might use those Shell aliases,

alias push='git nc && git push'
alias stat='git diff --stat --cached origin/master'

Create simple local repo

    cd somefolder/
    git init

For bare repo see Setting up a GIT bare repository. Note that you will not have to tell --bare when running gollum because we are using the rugged and not the grit adapter:

   --bare                       Declare '<git-repo>' to be bare. This is only necessary when using the grit adapter.

Basic usage

review the files that have been changed and commit,

git status
git commit -a

review what is going to be pushed and push,

git diff --stat --cached origin/master
git push

Create real (bare) repo that will be used remotely only

as git user on the GIT server,

    mkdir project.git/
    cd project.git/
    git init --bare

Using Github

Quoting Github's repo startup doc,

echo "# doc" >>
git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

…or push an existing repository from the command line

git remote add origin
git push -u origin master

Once your repo is up and running you can then fetch it using git-clone e.g.,

#git clone
git clone ssh://
#git clone


Fetch a remote repo

from a workstation or some server,

    git clone ssh://git@gitsrv/home/git/project.git

and if you are using Github or Gitlab, HTTP(S) is also available,

git clone
    git clone http://git@gitsrv/home/git/project.git

Fix commit message(s)


Push to a remote repo after you started already

you can also create your own,

    cd project/
    git init
    git add *
    #git add --all
    git commit -m MESSAGE

and sync with the remote repo afterwards,

    git remote add origin ssh://git@gitsrv/home/git/project.git
    #git config --global push.default simple
    git push
    #git push --set-upstream origin master

Create your own branch

first, choose the branch you want to pick from,

    git checkout release-1

then create yours,

    git branch release-1-with-my-feature
    git checkout release-1-with-my-feature

finally commit and eventually push your changes.

Merge changes

create a minor branch against release v1 for you and others to commit,

    git checkout release-1
    git branch release-1.1.0
    git checkout release-1.1.0

merge your changes into the new minor branch,

    git merge release-1-with-my-feature

Note. merge --no-ff if you like.

Deploy apps

update the list of branches and switch to the new minor branch,

    git fetch -a
    git checkout release-1.1.0
    #git pull

and restart the application.


to loose track of a git folder and work on it without commiting the changes,

cd git_repo/
git rm -r --cached folder/
git commit -m "Removed folder from repository"
git push origin master


on Github you may check your SSH keys' by fingerprint,

ssh-keygen -E md5 -lf ~/.ssh/

Handy tweaks

I am being lazy here -- for testing and internal purposes, when you do not want to play with certificate but actually play with something else,

#git config --global http.sslVerify false

to switch from HTTPS to SSH,

git remote -v
git remote set-url origin


Also this might be worth a look as for dealing with CRLF:


If you got shit like this when doing git diff,


==> enable "raw" control characters in your PAGER,

git config --global core.pager "less -r"

If you got this error,

error: Pull is not possible because you have unmerged files.

==> edit the file to proceed with the manual merge (see >>>>> lines...) and then,

git add merged_manually_file
git commit -m "manually merged"


Take over a broken local repo (commit during battery fallout):