Difference between revisions of "Git command summary"
Jump to navigation
Jump to search
m |
m |
||
| Line 8: | Line 8: | ||
*<code>-new-window</code> makes Sublime open a new window for the edit. | *<code>-new-window</code> makes Sublime open a new window for the edit. | ||
| − | *-wait makes sure that Sublime has focus until you close the file, this means that the script will wait, and not start Sublime as a sub-process and go on. | + | *<code>-wait</code> makes sure that Sublime has focus until you close the file, this means that the script will wait, and not start Sublime as a sub-process and go on. |
Make git call the script file (I assume it's not in your path): | Make git call the script file (I assume it's not in your path): | ||
Revision as of 11:41, 9 March 2017
Configuration
Editing the global configuration:
$git config --global --edit
Set git up to use Sublime Text
Create a batch/bash script that executes Sublime like this:
$subl -new-window -wait parameters to script
-new-windowmakes Sublime open a new window for the edit.-waitmakes sure that Sublime has focus until you close the file, this means that the script will wait, and not start Sublime as a sub-process and go on.
Make git call the script file (I assume it's not in your path):
$git config --global core.editor script incl. path
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