Skip to content

Instantly share code, notes, and snippets.

@IamAdamJowett
Last active September 13, 2015 22:58
Show Gist options
  • Save IamAdamJowett/d0cd0df546bff095d849 to your computer and use it in GitHub Desktop.
Save IamAdamJowett/d0cd0df546bff095d849 to your computer and use it in GitHub Desktop.
Handy git tricks

####Alias for a formatted changelog###

git config --global alias.changes '!git log --oneline --decorate > changelog.txt'

To export a changelog text file to the current directory named changelog.txt run:

git changes

####Alias for a formatted changelog with branch trees###

git config --global alias.changes '!git log --pretty=oneline --abbrev-commit --graph --decorate > changelog.txt'

To export to changelog.txt, run:

git changes

####Limit remote pushes to only current branch##

git config --global push.default tracking

####Checkout an old commit to a new branch

git checkout -b <branch name> <commit hash>

####Git Submodules

Adding a module

git submodule add <module git url> <location to add it to>

for example

git submodule add https://github.com/storypioneers/kirby-selector.git site/fields/selector

Updating sub modules

$ git submodule update --init --recursive
$ cd your/project/root
$ git submodule foreach git checkout master
$ git submodule foreach git pull
$ git commit -a -m "Update submodules"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment