Skip to content

Instantly share code, notes, and snippets.

@michaellihs
Last active April 11, 2017 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellihs/ec20000de92980d122785d5b28a3ec78 to your computer and use it in GitHub Desktop.
Save michaellihs/ec20000de92980d122785d5b28a3ec78 to your computer and use it in GitHub Desktop.
Git Cheat Sheet

Git Cheat Sheet

Extracting Repositories from Sub Paths

#!/usr/bin/bash

set -xue

projects=("subpath1" "subpath2" "subpath3" "subpath4" "subpath5")

for project in "${projects[@]}"
do
        rm -rf $project
        git clone $glbase/group/parent-repo.git $project
        cd $project
        git filter-branch --prune-empty --subdirectory-filter $project master
        git remote set-url origin ${glbase}/group/${project}.git
        git push origin master
        cd ..
done

Commits...

Changing commit messages of older commits

Use git rebase -i HEAD~n where n is the number of commits that you want to go back (+1).

An editor opens up - put reword in front of every commit that you want to change, save and close the editor.

You will now be asked to edit every commit message you wanted to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment