Difference between revisions of "Git command summary"
Jump to navigation
Jump to search
m |
m |
||
| Line 1: | Line 1: | ||
| − | == | + | ==Configuration== |
| + | Editing the global configuration: | ||
$'''git config --global --edit''' | $'''git config --global --edit''' | ||
==Branching== | ==Branching== | ||
| − | + | Creating a branch: | |
| − | |||
$'''git branch''' ''branch-name'' | $'''git branch''' ''branch-name'' | ||
| − | + | List branches: | |
$'''git branch''' | $'''git branch''' | ||
| − | + | Switch branch: | |
$'''git checkout''' ''branch-name'' | $'''git checkout''' ''branch-name'' | ||
| Line 17: | Line 17: | ||
==Committing== | ==Committing== | ||
| − | + | Commit changes: | |
$'''git commit -m "'''''Commit message goes here.'''''"''' | $'''git commit -m "'''''Commit message goes here.'''''"''' | ||
| − | + | Push committed changes: | |
$'''git push''' | $'''git push''' | ||
Revision as of 11:31, 9 March 2017
Configuration
Editing the global configuration:
$git config --global --edit
Branching
Creating a branch:
$git branch branch-name
List branches:
$git branch
Switch branch:
$git checkout branch-name
Staging
$git add file-name
Committing
Commit changes:
$git commit -m "Commit message goes here."
Push committed changes:
$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