DynDN.eS Blog

About DynDN.eS, eQmail, Gentoo & some other network stuff

User Tools

Site Tools

My GitHub (git) cheat sheet

  1. clone the repo from GitHub
  2. check out a development branch - make all changes with this branch
  3. push the development branch to GitHub
  4. create a Pull Request at GitHub

Use git at the command line

Create a new repository on GitHub. Then locally inside the source directory

#echo "# openqmail" >> README.md
$ git init
$ git add README.md
$ git commit -m "initial commit"
$ git remote add origin https://github.com/kai-peter/openqmail.git
$ git push -u origin master

Config Settings

$ git config user.name "Kai Peter"
$ git config user.email user@example.org
$ GIT_COMMITTER_NAME='kp' git commit --author="Kai Peter <user@example.org>" -m "Initial version"
$ git remote add origin https://github.com/kp-org/eQmail.git


Create a new branch “dev” (from master) on GitHub. Clone the repo and switch to branch “dev”:

$ git clone https://github.com/kp-org/eQmail.git
$ git checkout -b dev
$ git branch
$ * dev
$  master

Merge a dev branch into master

$ git checkout master
$ git merge dev

Delete the merged (old) branch (example: dev):

$ git branch -d dev

Checkout an older state: Create a new branch and check it out:

$ git checkout -b <branch> a9c146a09505837ec03b

Make changes and upload to remote GitHub repo:

$ git add *
$ git add .gitignore
$ git commit -a -m "<comment>"
$ git push origin dev

Hint::  git add  doesn't show what was added. Use  git status  to see what was added.

Remove files

Remove file from .git only:

$ git rm --cached <file>

Remove file completely: This removes <file> from filesystem too!

git rm <file>

Handle commits

Remove files from/after git add:

$ git reset [*|file]

Edit comment of last commit:

$ git commit --amend

Undo last commit:

$ git commit -m "Something terribly misguided"              (1)
$ git reset HEAD~                                           (2)
<< edit files as necessary >>                               (3)
$ git add ...                                               (4)
$ git commit -c ORIG_HEAD                                   (5)

Reset to an older commit:

git reset <commit-hash>


Get changes from remote repository (rebase, re-staging):

$ git pull https://github.com/kp-org/xdkim.git

Solving Conflicts

See this Link


Page Tools