Web Dev Notes

AboutContact

Useful Command

General command

Get documentation for a command:
$ git help [command]

Setting user name and email:
$ git config --global user.name "Name"
$ git config --global user.email [email]

Initializing a new git repository:
$ git init

Brief summary of the situation:
$ git status

Showing a list of everything across all branch
$ git reflog

Going back in time
$ git reset HEAD@{index}

Adding file

Adding all new files or modified files under the current directory:
$ git add .

Adding files:
$ git add file1 file2 file3

See what is about to be committed:
$ git diff --cached

Commit

Committing changes:
$ git commit

Adding and committing all modified files (not new one):
$ git commit -a

Changing the message on last commit
$ git commit --amend

Adding to the last commit
$ git commit --amend --no-edit

Project history

Project history:
$ git log

Project history with diff:
$ git log -p

Project history summary:
$ git log --stat --summary

Branching

Creating a new branch:
$ git branch [branch]

Listing all existing branches:
$ git branch

Switching to a branch:
$ git switch [branch]

Deleting branch
$ git branch -d [branch]

Merging

Merging a branch:
$ git merge [branch]

Showing the conflict:
$ git diff

Commit after resolving the conflicts:
$ git commit -a

Graphical representation of the resulting history:
gitk

Delete the merged branch

Pulling change

Useful Command

General command

Get documentation for a command:
$ git help [command]

Setting user name and email:
$ git config --global user.name "Name"
$ git config --global user.email [email]

Initializing a new git repository:
$ git init

Brief summary of the situation:
$ git status

Showing a list of everything across all branch
$ git reflog

Going back in time
$ git reset HEAD@{index}

Adding file

Adding all new files or modified files under the current directory:
$ git add .

Adding files:
$ git add file1 file2 file3

See what is about to be committed:
$ git diff --cached

Commit

Committing changes:
$ git commit

Adding and committing all modified files (not new one):
$ git commit -a

Changing the message on last commit
$ git commit --amend

Adding to the last commit
$ git commit --amend --no-edit

Project history

Project history:
$ git log

Project history with diff:
$ git log -p

Project history summary:
$ git log --stat --summary

Branching

Creating a new branch:
$ git branch [branch]

Listing all existing branches:
$ git branch

Switching to a branch:
$ git switch [branch]

Deleting branch
$ git branch -d [branch]

Merging

Merging a branch:
$ git merge [branch]

Showing the conflict:
$ git diff

Commit after resolving the conflicts:
$ git commit -a

Graphical representation of the resulting history:
gitk

Delete the merged branch

Pulling change