My Git cheat sheet

Init an empty Git repository or reinitialize an existing one

git init

Clone a repository

git clone https://mygitbucket.com/niklas/my_project.git

Pull in new changes from remote

git pull

Do a dry-run fetch to see what is comming

 git fetch --dry-run

Create a branch locally and checkout the branch

git checkout -b <name of branch>

Push the branch to remote

 git push origin <name of branch>

Delete local branch

git branch -d <name of branch>

Delete remote and local

git branch -D <name of branch>

Show all branches

 git branch -a

Add a remote subtree to your project. ‘common’ is here the name of the subtree

git remote add common https://mygitbucket.com/niklas/my_project.git

Do a ‘common pull’ i.e. pull a remote branch into to subtree. ‘common’ is here the name of the subtree (and folder)

git subtree pull -P common common my-subtree-branch --squash

List all remotes

git remote -v

Rename a local branch that you have checked out

git branch -m <new name>

Rename a branch you have not checked out

git branch -m <old name> <new name>

Check commits only in the current branch (descendent to master)

git log master..

Check commits only in the current branch (descendent to other branch)

git log master..<name of branch>

Create patch files for every commit in a interval of SHA’s

git format-patch <start SHA>..<stop SHA>

HEAD and other short codes work too
Create ONE patch file for all commits in the last 10 commits (from HEAD and back)

git format-patch -10 HEAD --stdout > my.patch

Apply a patch

git apply my.patch

Stash all uncommited modifications

git stash

Apply last saved stash to your current code

git stash apply

Apply last saved stash to your current code AND delete the stash

git stash pop

Manually delete the stash

git stash drop

My iKeycmd cheat sheet

# Add a client certificate to the Queue manager keystore (using stashed password)
ikeycmd -cert -add -db "key.kdb" -label ibmwebspheremqclient01 -file ibmwebspheremqclient01.crt -format ascii -stashed

# Remove certificate from Queue manager keystore (using stashed password)
ikeycmd -cert -delete -label ibmwebspheremqclient01 -db "key.kdb" -stashed

# Set default certificate (using stashed password)
ikeycmd -cert -setdefault -db key.kdb -stashed -label "mydefaultcertificate"

# List certificates
ikeycmd -cert -list personal -db "key.kdb" -pw changeit
ikeycmd -cert -list ca -db "key.kdb" -pw changeit

* List default signers
ikeycmd -cert -listsigners

Tested on IBM MQ 7.0.1.0 and Red Hat Linux 7

My Java Keytool cheat sheet

# List all entries in a jks
keytool -list -keystore mykeystore.jks -storepass changeit

# List detailed information about all entries in a jks
keytool -list -v -keystore mykeystore.jks -storepass changeit

# Rename an alias in a jks
keytool -changealias -alias "client01" -destalias "client02" -keystore mykeystore.jks -storepass changeit

# Remove an alias in a jks
keytool -delete -alias "client01" -keystore mykeystore.jks -storepass changeit

# Create a jks with a self-signed certificate
keytool -genkey -keyalg RSA -alias client01 -keystore mykeystore.jks -storepass changeit -validity 365 -keysize 2048

# Import a certificate to trust to a jks
keytool -import -alias server01 -file server01.crt -keystore mykeystore.jks

# Change jks keystore password 
keytool -storepasswd -keystore mykeystore.jks

# Change a jks key's password:
keytool -keypasswd  -alias <key_name> -keystore mykeystore.jks

# Extract certificate from a jks keystore
keytool -export -keystore mykeystore.jks -alias client01 -file client01.crt

Tested on Red Hat 7 and Java 8