Skip to content

Instantly share code, notes, and snippets.

@blokhin
Last active September 28, 2022 23:11
Show Gist options
  • Save blokhin/26c6db1ccad2231e05befe99425a0470 to your computer and use it in GitHub Desktop.
Save blokhin/26c6db1ccad2231e05befe99425a0470 to your computer and use it in GitHub Desktop.
# common GIT tips
git show HEAD~0:index.html
git log --graph --oneline --date-order --decorate --color --all
git diff --name-status master..somebranch
git diff somebranch master -- myfile
git commit --amend -m "New commit message"
git archive --format zip --output /full/path/to/zipfile.zip master
git archive --format tar --output ~/.tar master
git remote set-url origin git://new.url.here
git shortlog -s -n
git checkout otherbranch myfile.txt
git ls-tree -r master --name-only
# NB non empty repo init
git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master
# Pull request from fork to upstream
git remote add upstream https://github.com/whatever/whatever.git
git fetch upstream
# SUBMODULES
git add .gitmodules
git submodule add https://github.com/mpds-io/mpds-ml-labs.git gen/ml
git submodule update --remote gen/ml
git submodule foreach --recursive 'git pull origin gh-pages'
git submodule update --init --recursive
# offline usage
git bundle create repo.bundle --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment