Skip to content

Instantly share code, notes, and snippets.

@paulvollmer
Last active August 14, 2019 06:02
Show Gist options
  • Save paulvollmer/4125238 to your computer and use it in GitHub Desktop.
Save paulvollmer/4125238 to your computer and use it in GitHub Desktop.
Clone with submodules

#git cheat sheet

##$ git clone Clone into a custom named folder

git clone git@github.com/username/repository.git foldername

Clone the last five commits

git clone --depth=5 git@github.com/username/repository.git

Clone with submodules

git clone git@github.com/username/repository.git --recursive

##$ git add Add file1 and all files from directory dir1 to git index

git add file1 dir1

Add all not ignored files to git index

git add --all

##$ git mv Rename file/folder

git mv [old] [new]

##$ git checkout Switch Branch

git checkout [branchname]

Create a New and Empty Branch

git checkout --orphan branchname
git rm -rf .
git push origin branchname
# Add a placeholder file to push the empty branch to github
echo "placeholder" > place.holder
git add .
git commit -a -m "Add Placeholder. First commit on this branch"
git push origin branchname

##$ git tag Add a tag

git tag -a v1 -m "Version 1 release"  
git push --tags  

Delete a tag

git tag -d v1

##$ git submodule Add a submodule

git submodule add git@github.com:username/repo.git path/for/submodule

Initialize and update a submodule

git submodule init
git submodule update

##Frontends gitk
Open the gitk revisionbrowser

gitk

Open the last 100 commits

gitk -n 100

Show all commits that change README

gitk -- README

Show changes since 01.06.2012

gitk --since=2012-06-01

Show changes until 01.06.2012

gitk --until=2012-06-01

Start from commit abc123

gitk --select-commit=abc123

All commits from abc123 to HEAD

gitk abc123..HEAD

git gui
Start the browser mode

git gui

Standard mode

git GUI browser

Blame output for README

git gui blame README

Quit git gui after one commit

git gui citool

Get the version of git gui

git gui version

instaweb
Start instaweb

git instaweb

Start at 127.0.0.1 on port 8888

git instaweb --local --port 8888

Set the Webbrowser

git instaweb -p 4000 --browser chrome

Set the HTTP-Server to the Ruby webrick Server

git instaweb --httpd webrick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment