Git store data as snapshots of the project over time. Git is check-summed before it is stored and is then referred to by that checksum. The mechanism that Git uses for this checksumming is called a SHA-1 hash. This is a 40-character string composed of hexadecimal characters (0–9 and a–f): 24b9da6552252987aa493b52f8696cd6d3b00373
Git has three main states that your files can reside in: modify, commit, and stage.
The basic Git workflow goes something like this:
Git Configuration can be stored in three different locations:
Initial Setup
Show help for a command
git help command
git command --help
Cloning a project (get a copy of a project):
git clone [ssh://, http(s)://, git://]/URLS/path/to/file.git
For example:
git clone git://git.kernel.org/pub/scm/git/git.git
Initialize a new repository:
git init
File Operations
Add file or files in directory recursively:
git add path
Remove file or directory from the working tree
git rm path
Showing differences between working and local repository:
git diff
Showing the differences between working and index:
git diff --cached
Show the brief summary of the situation:
git status
Commit from index to local repository, if you have not added to the index repository, it won't be committed:
git commit [file,directory]
Commit from working straight to local repository:
git commit -a [file,directory]
Branch Operation
Show the local branches:
git branch
Show all branches including the remote repository:
git branch -a
Get a copy of the Entire remote repository without merging them into your local:
git fetch origin
Create a remote branch on the GIT server using the master refs:
git push origin origin:refs/heads/NEW_BRANCH_NAME
Create a remote branch on the GIT server using some other branch refs:
git push origin origin/SOME_BRANCH_NAME:refs/heads/NEW_BRANCH_NAME
Check out the new branch and track it on the localhost:
git checkout --track -b NEW_BRANCH_NAME origin/NEW_BRANCH_NAME
Remove a remote branch on the GIT server:
git push origin :heads/BRANCH_NAME
Remove the remote branch from your localhost:
git branch -r -d origin/BRANCH_NAME
Remove the unmerge local branch on the localhost:
git branch -D BRANCH_NAME