-
Notifications
You must be signed in to change notification settings - Fork 6
Git Cheat Sheet
Oğuz Kaan Yüksel edited this page Mar 24, 2018
·
8 revisions
This page contains the mostly used git commands and their usage areas.
Please refer to Learn Git page and resources suggested there for detailed info.
For a more comprehensive cheatsheet, checkout Atlassian Cheatsheet.
Usage | Command |
---|---|
Set your name | git config --global user.name "[name]" |
Set your e-mail | git config --global user.email "[email address]" |
Usage | Command |
---|---|
Initialize a repository | git init |
Clone a repository | git clone |
Usage | Command |
---|---|
Lists all new or modified files to be committed | git status |
Add your modified files | git add [file] |
Commit your changes | git commit -m "Commit Message" |
Push to master | git push origin master |
Unstage a file | git reset [file] |
Show the file differences | git diff [path] |
Usage | Command |
---|---|
List all local branches | git branch |
Create a new branch | git branch [branch-name] |
Switch to a specific branch | git checkout [branch-name] |
Merge the current branch with the given branch | git merge [branch] |
Delete the given branch | git branch -d [branch-name] |
Show the differences between the given branches | git diff [first-branch]...[second-branch] |
Follow actions below in correspondence with our Contribution Guide.
- Make your changes
- Add your changes to staging area by (multiple directory or file):
git add <file>
- Reset unwanted changes from staging
git reset <file>
- Save your changes
git commit
- Create a new branch
git branch <branch>
- Switch to the newly created branch
git checkout <branch>
- Work in local
- Pull changes
git pull <branch>
- Work in local
- Submit your changes
git push <branch>
- Retrieve new content
git fetch <branch>
- Rebase new content to start of your branch
git rebase <remote>/<branch>
-
Or one liner:
git pull --rebase <remote> <branch>