Star

Created With

linkGit Aliases

There are two (perhaps more!) but mainly two ways to set up aliases for your git on your shell.

linkOption 1, using a bash alias

linkStop the dreaded error pushing to remote when making your first push. Never again!

1link$alias gp='git push -u origin HEAD'

linkPush your local changes. Quick!!!

1link$function acp() {

2link$git add .

3link$git commit -m "$1"

4link$git push -u origin HEAD

5link$}

6link$

linkCreate a new repo in a single command with readme and remote repository set up

1link$function gitnewrepo() {mkdir $1 && cd $1 && git init && hub create && touch README.md && echo "# " $1 >> README.md && git add . && git commit -m "init" && git push -u origin HEAD;}

linkOption 2 Using a global git alias (place in your global .gitconfig)

linkAdd a nice alias for log (no newlines)

1link$git config --global alias.l "log

2link$ --graph

3link$ --pretty=oneline

4link$ --abbrev-commit

5link$ --decorate"

6link$git l

linkEasily undo the last changes you made with a new git undo command

1link$git config --global alias.undo reset HEAD~1 --mixed

linkView your last commit

1link$git config --global alias.last 'log -1 HEAD --stat'

linkGet a list of your git aliases

1link$git config --global alias.gl 'config --global -l'

Git AliasesOption 1, using a bash aliasStop the dreaded error pushing to remote when making your first push. Never again!Push your local changes. Quick!!!Create a new repo in a single command with readme and remote repository set upOption 2 Using a global git alias (place in your global .gitconfig)Add a nice alias for log (no newlines)Easily undo the last changes you made with a new git undo commandView your last commitGet a list of your git aliases
Content

Home Backstory Why Git? Setting Up GitHub GitHub CLI Your GitHub Profile GitHub Pages Creating A New Repo Cloning A Repository Your First Commit Ignoring Files In Git Stashing Your Changes Branching With Git Merging Git Branches Rebasing Vs Merging Git Workflows Fork And Pull Flow Your First Pull Request Automated Security Alerts Seeing The Differences Removing/Deleting Files Reverting Your Commits Configuring your Git Commit Templates Creating Shortcuts Dotfile Management Sponsoring Open Source Handy Commands Thank You



Developer Student Clubs

logo2.png