Common Commands

Short Description Command Description
Add git add <pattern>  
Add All git add -u Add all pending changes.
Clean git clean Clean all untracked changes.
Clean Preview git clean -n  
Clone Repository git clone <project URL>  
Commit Pending git commit -m "<message>"  
Initialize Repository git init <project name>  
Move git mv <source> <target>  
Pull from Master git pull origin master  
Push to Master git push origin master  
Remove git rm <target>  
Revert git revert <version>  
Repository Status git status  
View Pending git log origin/master..HEAD  
View Pending Diff git diff origin/master..HEAD  

Special Workflows

Reset History

#!/bin/bash

git checkout --orphan latest_branch
git add -A
git commit -am "Initial commit."
git branch -D master
git branch -m master
git push -f origin master
rm -rf .git;
git init;
git add .;
git commit -m "Initial commit";
git remote add origin https://github.com/<username>/<repo>.git;
git push -u --force origin master;

Delete Tag

Can be used to delete tags upstream (e.g. GitHub).

git push --delete origin v1.0

Other Options

Cache credentials for a day.

git config credential.helper 'cache --timeout 86400'

Resources

Tags:

Updated:

Leave a comment