Git Cheatsheet

Just some git stuff

Using multiple git account

vi ~/.ssh/config

Host gitlab.com
    HostName gitlab.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes

Host gitlab-work
    HostName gitlab.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_work
    IdentitiesOnly yes

Clear the cache:

ssh-add -D

Add all ssh keys:

ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/id_work

Now clone your project:

git clone gitlab-work:work/project.git

Troubleshooting:

export GIT_SSH_COMMAND="ssh -v"

If you also want to separate private and work email addresses, you have to set the user and email per project and no longer globally (omit the --global):

git config user.name "Jorg Bosman"
git config user.email "<your email address>"

History

git log --pretty=oneline --max-count=2
git log --pretty=oneline --since='5 minutes ago'
git log --pretty=oneline --until='5 minutes ago'
git log --pretty=oneline --author=<your name>
git log --pretty=oneline --all

And my favourite:

git log --all --pretty=format:"%h %cd (%an) %s" --since='7 days ago' --date=short

Githubiverse website template

from https://help.github.com/articles/creating-project-pages-manually:

cd ~/src/yourproject
git checkout --orphan gh-pages
git rm -rf .
git rm -rf .gitignore # if exists

echo "My GitHub Page" > index.html
git add index.html
git commit -a -m "First commit"
git push origin gh-pages

Setup url redirect:

echo "src.jorgbosman.nl" > CNAME
git add CNAME
git commit -m "Setting cname rewrite"
git push origin gh-pages

Create a cname in your domain:

src IN CNAME jorgbosman.github.io

Switch back to the master branch:

git checkout master