- Download git autocompletion script using following CURL command
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
- Open
~/.bash_profile
file (~/.bash_rc
if use Linux) and add the following
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
- Then execute
source ~/.bash_profile
command in terminal
Create new branch from existing branch
git checkout -b <new_branch> <current_branch>
Delete local and remote branches through commandline
#Delete local branch
git branch -d <branch_name>
#Delete remote branch
git push --delete <remote_name> <branch_name>
Use following commands to store git credentials permanently on macOS or Ubuntu
Config to use global credentials store
$ git config --global credential.helper store
$ git pull
Store password in Cache for 1 year
$ git config --global credential.helper 'cache --timeout=31557600'
Following commands will prompt for username and password
git config --local credential.helper ""
git push origin master