Difference between revisions of "Git command summary"

From Jens' Hjørne
Jump to navigation Jump to search
m
m
Line 2: Line 2:
  
 
===Create branch===
 
===Create branch===
−
  '''git branch''' ''branch-name''
+
  $'''git branch''' ''branch-name''
  
 
===Display branches===
 
===Display branches===
−
  '''git branch'''
+
  $'''git branch'''
  
 
===Switch branch===
 
===Switch branch===
−
  '''git checkout''' ''branch-name''
+
  $'''git checkout''' ''branch-name''
  
 
==Staging==
 
==Staging==
−
  '''git add''' ''file-name''
+
  $'''git add''' ''file-name''
  
 
==Committing==
 
==Committing==
 
===Commit===
 
===Commit===
−
  '''git commit -m "'''''Commit message goes here.'''''"'''
+
  $'''git commit -m "'''''Commit message goes here.'''''"'''
  
 
===Push===
 
===Push===
−
  '''git push'''
+
  $'''git push'''
  
 
==Diffing==
 
==Diffing==
 
To see a diff list of changes made to the files on disk:
 
To see a diff 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 diff list of changes made to the staged files:
−
  '''git diff --cached'''
+
  $'''git diff --cached'''
 +
 
 +
==Update changed code==
 +
To update code that has changed you need to 'stash' the changed code, pull the updated code and 'unstash' the stashed code:
 +
$'''git stash'''
 +
$'''git pull --rebase'''
 +
$'''git stash apply'''
  
 
[[Category:Værktøjer, Programmering]][[Category:Keyboard shortcuts]]
 
[[Category:Værktøjer, Programmering]][[Category:Keyboard shortcuts]]

Revision as of 11:59, 6 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 diff list of changes made to the files on disk:

$git diff

To see a diff list of changes made to the staged files:

$git diff --cached

Update changed code

To update code that has changed you need to 'stash' the changed code, pull the updated code and 'unstash' the stashed code:

$git stash
$git pull --rebase
$git stash apply