Git AliasesYou can add extra git commands in the command line to make your life easier using git alias
if you type git config --global -e you will be able to edit these.
they should go inside the [alias] section (add one if it's not there)
These commands are just simple aliases for anything that I use a lot, mainly because I have to type less to use them.
s = statusSee the status of the repository
c = commitCommit changes to the local repository
cm = commit -mCommit with a message
git cm "Updated some code stuff"
aa = add -AStages all the changes in the workspace.
co = checkoutCheckout a branch or commit.
git co master
lga = log --graph --oneline --all --decorate
Shows the history for the repository in a nice way.
lgab = log --graph --oneline --decorateShows the history for the current branch in a nice way.
Pushing & Pulling
plr = pull --rebase
pull but rebase instead of merge, find this useful when working on a branch that have others working in it to avoid merge commits. Makes the history much cleaner. See the internet for arguments about this.
pushup = "!git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\""Push a local branch to the origin remote, does what it says on the tin. Use this lots when working within a feature branch/pull request workflow.
Stash & ResetMost of these I found on Phil Haacks blog
wip = !git add -A && git commit -m 'WIP'
Work in progress commit, commits anything to the current branch so it can be reverted later. Useful if you need to change what you are working on. You could use git stash but I prefer having a proper commit.
load = reset HEAD~1 --mixedUsed to undo the commit that was done with the wip command and put the changes in the working directory.
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hardReally like this one, use it instead of "git reset --hard" to clear the current working directory. Much better because it still commits the changes before wiping so they will remain in your local repository until they are garbage collected.
Post a Comment