Skip to content
Marie-Louise edited this page Oct 3, 2018 · 34 revisions

Basics

General

move back one directory

$ cd ..

check status

$ git status

to add updated files

$ git add <file_path>

to undo git add and remove file from staging

$ git reset <file_path>

to save changes and add a comment

$ git commit -m "<first commit>"

To show file the differences of files not yet staged

$ git diff

To show differences between staged files and the last file version

$ git diff --staged

to check the differences between branches

$ git diff <branch_name> <other_branch_name>

to see the history of activity/ git commands on that branch

$ history

to see the last 10 commands

$ history 10

Update master branch

$ git checkout master

$ git fetch origin - p

$ git reset --hard origin/master

$ git log

NOTE:

$ git fetch origin 

can be executed on any branch

Create repositories

to create a new repo

$ git init <project_name>

to download an existing repo with it's version history

$ git clone <URL>

Branch

create new branch

$ git checkout -b <local_branch_name>

delete branch

$ git branch -d <local_branch_name>

display full list of git branches

$ git branch -a

to check current branch

$ git branch

Push local branch

$ git push origin <local_branch_name>

view the history

$ git log

Switch branches

$ git checkout <local_branch_name>

Remove file from staging

$ git rm <file_name>

Other

Setting up Drupal environment in AWS

Clone this wiki locally