Some few updates/additions; clean up formatting
This commit is contained in:
committed by
Pasi Kallinen
parent
a873129caf
commit
4c28a96b92
@@ -3,13 +3,13 @@ reference for basic tasks while you get up to speed.
|
|||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
git checkout [-f] (branch)
|
[*] git checkout [-f] (branch)
|
||||||
|
|
||||||
Switch your local repository to be at the most recent commit of (branch).
|
Switch your local repository to be at the most recent commit of (branch).
|
||||||
Including -f will discard changes made in the working directory.
|
Including -f will discard changes made in the working directory.
|
||||||
|
|
||||||
|
|
||||||
git status [-uall | -uno]
|
[*] git status [-uall | -uno]
|
||||||
|
|
||||||
Shows all changed files in your local repository and also a list of the ones
|
Shows all changed files in your local repository and also a list of the ones
|
||||||
you have staged for commit.
|
you have staged for commit.
|
||||||
@@ -17,10 +17,10 @@ Including -uall will also show you all untracked files in all subdirectories.
|
|||||||
Including -uno will show you _no_ untracked files.
|
Including -uno will show you _no_ untracked files.
|
||||||
|
|
||||||
|
|
||||||
git log [-NUM]
|
[*] git log [-NUM]
|
||||||
git log <commit1> <commit2>
|
[*] git log <commit1> <commit2>
|
||||||
git log [--pretty=one]
|
[*] git log [--pretty=one]
|
||||||
git log (branch)
|
[*] git log (branch)
|
||||||
|
|
||||||
For a full explanation of all the arguments you can pass to 'log', please see
|
For a full explanation of all the arguments you can pass to 'log', please see
|
||||||
the manual; there are a lot and these are just a few of the common ones. For
|
the manual; there are a lot and these are just a few of the common ones. For
|
||||||
@@ -33,13 +33,13 @@ you specify:
|
|||||||
(branch): show the commits from (branch) instead of the current one
|
(branch): show the commits from (branch) instead of the current one
|
||||||
|
|
||||||
|
|
||||||
git add (filename)
|
[*] git add (filename)
|
||||||
|
|
||||||
Adds the changes you've made in (filename) to the pre-commit staging area.
|
Adds the changes you've made in (filename) to the pre-commit staging area.
|
||||||
(also referred to as the 'index')
|
(also referred to as the 'index')
|
||||||
|
|
||||||
|
|
||||||
git commit [-a] [-m "text"]
|
[*] git commit [-a] [-m "text"]
|
||||||
|
|
||||||
Commits all staged changes (in the index) to this branch in your local repo
|
Commits all staged changes (in the index) to this branch in your local repo
|
||||||
from your current position.
|
from your current position.
|
||||||
@@ -48,7 +48,7 @@ Including -m will use "text" as the commit message instead of opening an
|
|||||||
editor window for you to create one.
|
editor window for you to create one.
|
||||||
|
|
||||||
|
|
||||||
git push [--all] [-u origin (branch)]
|
[*] git push [--all] [-u origin (branch)]
|
||||||
|
|
||||||
Sends all your commits for the current branch to the centralized repo.
|
Sends all your commits for the current branch to the centralized repo.
|
||||||
Including --all will send the commits for _all_ branches.
|
Including --all will send the commits for _all_ branches.
|
||||||
@@ -57,11 +57,11 @@ created; it establishes the connection between local and remote for that
|
|||||||
branch.
|
branch.
|
||||||
|
|
||||||
|
|
||||||
git reset [--hard] (filename)
|
[*] git reset [--hard] (filename)
|
||||||
|
|
||||||
Without any parameters, unstages the changes for (filename) from the index;
|
Without any parameters, unstages the changes for (filename) from the index;
|
||||||
does not change the working tree. This is the equivalent of the command
|
does not change the working tree. This is the equivalent of the command
|
||||||
git reset --mixed (filename); git reset --soft (filename) has no effect.
|
[*] git reset --mixed (filename); git reset --soft (filename) has no effect.
|
||||||
|
|
||||||
With --hard, unstages (filename) from the index and reverts (filename) in
|
With --hard, unstages (filename) from the index and reverts (filename) in
|
||||||
the working tree to the most recent commit.
|
the working tree to the most recent commit.
|
||||||
@@ -74,7 +74,7 @@ with it. But at the same time, for people who are adapting to a commit not
|
|||||||
also automatically being a send, it's nice for them to know how to undo one in
|
also automatically being a send, it's nice for them to know how to undo one in
|
||||||
case they do something wrong. thoughts?]
|
case they do something wrong. thoughts?]
|
||||||
|
|
||||||
git reset [--soft | --mixed | --hard] HEAD~1
|
[*] git reset [--soft | --mixed | --hard] HEAD~1
|
||||||
|
|
||||||
*** WARNING *** Never, EVER do this to a commit that you have already pushed;
|
*** WARNING *** Never, EVER do this to a commit that you have already pushed;
|
||||||
you will be rewriting history on other people's machines and this will
|
you will be rewriting history on other people's machines and this will
|
||||||
@@ -90,26 +90,79 @@ With --hard, does everything --mixed does but also reverts the working tree to
|
|||||||
the prior commit.
|
the prior commit.
|
||||||
|
|
||||||
*** WARNING *** --hard will effectively delete a commit and "lose" the changes.
|
*** WARNING *** --hard will effectively delete a commit and "lose" the changes.
|
||||||
|
[/end area-of-concern]
|
||||||
|
|
||||||
|
|
||||||
git fetch [-a]
|
[*] git fetch [-a]
|
||||||
|
|
||||||
Retrieve commits from the remote repository to your machine.
|
Retrieve commits from the remote repository to your machine.
|
||||||
Including -a will get commits for all branches.
|
Including -a will get commits for all branches.
|
||||||
|
Does NOT merge them into your local repository.
|
||||||
|
|
||||||
|
|
||||||
git pull
|
[*] git pull
|
||||||
|
|
||||||
Incorporate any fetched commits for the current branch into your repository
|
Incorporate any fetched commits for the current branch into your repository
|
||||||
and update your position accordingly.
|
and update your position accordingly. This will create a merge commit (noting
|
||||||
|
that you merged a branch into itself).
|
||||||
|
|
||||||
|
|
||||||
git merge (branch) [--no-commit]
|
[*] git rebase [no-arguments version ONLY]
|
||||||
|
|
||||||
|
Incorporate fetched commits for the current branch into your repository, and
|
||||||
|
replay any local commits and changes afterwards on top.
|
||||||
|
|
||||||
|
Quality picture-pages ASCII art:
|
||||||
|
|
||||||
|
E---F---G---H (remote changes)
|
||||||
|
/
|
||||||
|
/
|
||||||
|
(branch 'frog') A---B---C---D---E'---F' (your local changes)
|
||||||
|
|
||||||
|
After 'git fetch' and 'git rebase', it will look like this:
|
||||||
|
|
||||||
|
--- (remote HEAD)
|
||||||
|
|
|
||||||
|
V
|
||||||
|
(branch 'frog') A---B---C---D---E---F---G---H---E'---F'
|
||||||
|
^ ^
|
||||||
|
| |
|
||||||
|
-------- (to be pushed)
|
||||||
|
|
||||||
|
|
||||||
|
[*] git branch (branch)
|
||||||
|
|
||||||
|
Creates a new branch from the current commit you're pointed to.
|
||||||
|
Does not automatically checkout (switch to) the branch.
|
||||||
|
|
||||||
|
|
||||||
|
[*] git checkout -b (branch)
|
||||||
|
|
||||||
|
Creates a new branch from the current commit you're pointed to, and
|
||||||
|
automatically checks out that branch.
|
||||||
|
|
||||||
|
|
||||||
|
[*] git branch <pattern> --list | [--all | -a] | [--remotes | -r]
|
||||||
|
|
||||||
|
Lists all branches matching <pattern>.
|
||||||
|
With --all instead, lists all branches (including remotely tracked ones).
|
||||||
|
With --remotes instead, lists only remote branches.
|
||||||
|
|
||||||
|
|
||||||
|
[*] git merge (branch) [--no-commit]
|
||||||
|
|
||||||
Merges all the changes from (branch) since it last diverged from a common
|
Merges all the changes from (branch) since it last diverged from a common
|
||||||
ancestor into your current branch.
|
ancestor into your current branch.
|
||||||
|
|
||||||
With --no-commit, does not automatically create a merge entry in the log but
|
With --no-commit, does not automatically create a merge entry in the log but
|
||||||
leaves all the merged files in your working directory; to complete the merge
|
leaves all the merged files in your working directory; to complete the merge
|
||||||
you must commit them manually later (likely after you have edited them).
|
you must commit them manually later (likely after you have edited them). This
|
||||||
|
more accurately mimics the merge behavior of svn [and cvs?]
|
||||||
|
|
||||||
|
|
||||||
|
=======================================
|
||||||
|
Typical workflows for common activities
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
{To be added in near future: DSR 3/15}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user