Set up and initialization

git init

git clone [url]

Staging and Snapshot

git status

git add [filename]

git reset [filename]

git diff [filename]

git diff --staged

git commit -m "commit message"

git commit --amend

Branching and Merging

git branch

git checkout [branch-name]

git branch [new-branch-name] git checkout [new-branch-name]

git checkout -b [new-branch-name]

git branch -d [branch-name]

git branch -D [branch-name]

git branch -m [new-branch-name]

git merge [branch]

git log

git log [branch-b]..[branch-a]

git diff [branch-b]...[branch-a]

Sharing and updating

git push origin [branch]

git pull

git fetch

git reset --hard [commit]

git reflog show

Stashing - Temporary Commits

git stash

git stash list

git stash pop

git stash drop

git stash apply

Git is the most widely used version control system in the world. It is free and open source project which tracks changes in the working files of a user and coordinate changes in those working files amongst multiple users.The most important and basic commands for Git are:initialize an existing directory as a Git repository/create a new git repository.creates a working copy of an existing repo.displays the state of the working directory staged for your next commit.moves the changes from the actual directory to the staging area.removes the specified file from the staging area but leaves the working directory unchanged.difference of what is changed but not staged.difference of what is staged but not committed.takes the staged snapshot and commits it to the HEAD.lets you amend the most recent commit.lists all your branches. A (*) will appear next to the name of your currently active branch.navigates to the specified branch and updates the working directory to match.creates a new branch and switch to it at the same time.or short hand for above code is:creates a new branch and switch to it at the same time.deletes the specified branch. It is a safer option in which Git prevents you from deleting the branch if it has unmerged changes.force deletes the specified branch even if it has unmerged changes.renames the current branch to the new specified name.merges the specified branch's history into the currently active branch.shows all the commits in the current branch's history.shows the commits on branch-a that are not on branch-b.shows the difference of what is in branch-a that is not in branch-bmakes your branch available to others by pushing your branch to remote repository.fetches and merges any commits from the tracking remote branch.fetches any commits from the tracking remote branch but does not automatically merge them. So, the local stays the same.clears the staging area, rewrite working tree from the specified commit.shows a record of your references. It displays each position of HEAD in the last 30 days(by default).takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy.lists stack-order of stashed file changes.writes working from top of stash stack.discards the changes from top of stash stack.applies the changes from the top of stash stack.