(Image credit: git-scm.com)
Basic usage of the commonly-used version control system git.
Create a new Git repository
cd <directory>
git init
Inspects the contents in the directory and staging area
git status
Add files from working directory to staging area
git add <filename>
git add *
Modify the file
Show difference between working directory and staging area
git diff
Commit the changes
git commit -m "Message"
Show allp revious commits
git log
Show the most recent commit
git show HEAD
Restore the file in the working directory to the previous staging version
git checkout HEAD <filename>
Unstage a file
git reset HEAD <filename>
Return to a previous stage
git reset <SHA first 7 characters>
Check branchs (* indicates the current one)
git branch
Create a new branch
git branch <branch name>
Switch to another branch
git checkout <another branch name>
Delete a branch
git branch -d <branch name>
Clone a git
git clone <source_name> <target_name>
List remotes
git remote -v
Check changes in the remote
git fetch
Merge with remote
git merge origin/master
Push your branch to the origin
git push origin <your branch>