Difference between revisions of "Git command summary"

From Jens' Hjørne
Jump to navigation Jump to search
Line 21: Line 21:
  
 
==Diffing==
 
==Diffing==
−
To see a diff list of changes made to the files on disk:
+
To see a list of changes made to the files on disk:
 
  $'''git diff'''
 
  $'''git diff'''
  
−
To see a diff list of changes made to the staged files:
+
To see a list of changes that have been staged:
 
  $'''git diff --cached'''
 
  $'''git diff --cached'''
  

Revision as of 09:50, 8 March 2017

Branching

Create branch

$git branch branch-name

Display branches

$git branch

Switch branch

$git checkout branch-name

Staging

$git add file-name

Committing

Commit

$git commit -m "Commit message goes here."

Push

$git push

Diffing

To see a list of changes made to the files on disk:

$git diff

To see a list of changes that have been staged:

$git diff --cached

Update changed code

To update code that has changed on the master branch, you need to 'stash' the changed code, pull the updated code and 'unstash' the stashed code. You may also have to switch branches in the process:

$git stash
$git checkout master
$git pull --rebase
$git checkout branch-you-came-from
$git stash apply