Skip to content
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.

Cheatsheet

Configure Your Git Profile

Usage Command
Set your name git config --global user.name "[name]"
Set your e-mail git config --global user.email "[email address]"

Create Repositories

Usage Command
Initialize a repository git init
Clone a repository git clone

Make Changes

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]

Group Changes/Branches

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]

How to's

Follow actions below in correspondence with our Contribution Guide.

Work in local

  • 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 isolation

  • Create a new branch
    • git branch <branch>
  • Switch to the newly created branch
    • git checkout <branch>
  • Work in local

Work together

  • Pull changes
    • git pull <branch>
  • Work in local
  • Submit your changes
    • git push <branch>

Handle conflicts

  • 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>
Clone this wiki locally