Git is a distributed revision control and source code management and was initially designed and developed by Linus Torvalds for Linux kernel development. Git is a free software distributed under the terms of the GNU General Public License version 2

I frequently use the following cheat sheet that I have created:

# Sets the name globally for your commits
git config --global "[your name]"

# Sets the email globally for your commits
git config --global "[your email]"
# Initialize a new local repository
git init [repository name]

# Clone a remote repository
git clone [url]
# List new/modified files to be committed
git status

# List file differences not yet staged
git diff

# Add a file
git add [filename | *]

# Remove files which have been deleted, update what was modified and add new files
git add -u

# Commit a file (records snapshot permanently in version history)
git commit -m "some commit message"

# Push all commit changes
git push

# Pull all changes
git pull

Some helpful commands

# Show all remote/local branches
git branch -a

# Show all remote branches
git branch -r

# Show unpushed commits that are local
git log --branches --not --remotes

# Delete a local branch
git branch -d local_branch

# Remove this branch on remote
git push origin :local_branch

# Remove a remote branch that is not local
git push origin --delete remote_branch

# Make develop identical to master
git branch -f develop master

# Make develop identical to master, if you are already on develop branch
git reset —hard develop master

# Merge master into develop
git checkout develop
git fetch origin
git merge origin/master

# --prune after fetching, remove any remote-tracking branches which no longer exist on the remote
git fetch -p

# push a new local branch (from local to remote i.e. set upstream)
git push >& git.tmp ; cat git.tmp | sed -n 4p | `sed 's/^[[:space:]]*//g; s/[[:space:]]*$//'` && rm git.tmp

# Squash all commits on master branch
git checkout master
git checkout --orphan feature/squashed
git add -A && git commit -am "Squash all commits and start fresh"
git branch -D master
git branch -m master
git push -f origin master