mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-26 15:13:56 +00:00
add Git resource
This commit is contained in:
parent
9e2bd7c11b
commit
2af4f99b67
@ -26,11 +26,11 @@ Version control is a system that records changes to a file(s), over time.
|
|||||||
|
|
||||||
### Centralized Versioning vs. Distributed Versioning
|
### Centralized Versioning vs. Distributed Versioning
|
||||||
|
|
||||||
* Centralized version control focuses on synchronizing, tracking, and backing
|
* Centralized version control focuses on synchronizing, tracking, and backing
|
||||||
up files.
|
up files.
|
||||||
* Distributed version control focuses on sharing changes. Every change has a
|
* Distributed version control focuses on sharing changes. Every change has a
|
||||||
unique id.
|
unique id.
|
||||||
* Distributed systems have no defined structure. You could easily have a SVN
|
* Distributed systems have no defined structure. You could easily have a SVN
|
||||||
style, centralized system, with git.
|
style, centralized system, with git.
|
||||||
|
|
||||||
[Additional Information](http://git-scm.com/book/en/Getting-Started-About-Version-Control)
|
[Additional Information](http://git-scm.com/book/en/Getting-Started-About-Version-Control)
|
||||||
@ -57,7 +57,7 @@ A git repository is comprised of the .git directory & working tree.
|
|||||||
|
|
||||||
### .git Directory (component of repository)
|
### .git Directory (component of repository)
|
||||||
|
|
||||||
The .git directory contains all the configurations, logs, branches, HEAD, and
|
The .git directory contains all the configurations, logs, branches, HEAD, and
|
||||||
more.
|
more.
|
||||||
[Detailed List.](http://gitready.com/advanced/2009/03/23/whats-inside-your-git-directory.html)
|
[Detailed List.](http://gitready.com/advanced/2009/03/23/whats-inside-your-git-directory.html)
|
||||||
|
|
||||||
@ -68,15 +68,15 @@ referred to as your working directory.
|
|||||||
|
|
||||||
### Index (component of .git dir)
|
### Index (component of .git dir)
|
||||||
|
|
||||||
The Index is the staging area in git. It's basically a layer that separates
|
The Index is the staging area in git. It's basically a layer that separates
|
||||||
your working tree from the Git repository. This gives developers more power
|
your working tree from the Git repository. This gives developers more power
|
||||||
over what gets sent to the Git repository.
|
over what gets sent to the Git repository.
|
||||||
|
|
||||||
### Commit
|
### Commit
|
||||||
|
|
||||||
A git commit is a snapshot of a set of changes, or manipulations to your
|
A git commit is a snapshot of a set of changes, or manipulations to your
|
||||||
Working Tree. For example, if you added 5 files, and removed 2 others, these
|
Working Tree. For example, if you added 5 files, and removed 2 others, these
|
||||||
changes will be contained in a commit (or snapshot). This commit can then be
|
changes will be contained in a commit (or snapshot). This commit can then be
|
||||||
pushed to other repositories, or not!
|
pushed to other repositories, or not!
|
||||||
|
|
||||||
### Branch
|
### Branch
|
||||||
@ -91,13 +91,13 @@ functionality to mark release points (v1.0, and so on)
|
|||||||
|
|
||||||
### HEAD and head (component of .git dir)
|
### HEAD and head (component of .git dir)
|
||||||
|
|
||||||
HEAD is a pointer that points to the current branch. A repository only has 1
|
HEAD is a pointer that points to the current branch. A repository only has 1
|
||||||
*active* HEAD.
|
*active* HEAD.
|
||||||
head is a pointer that points to any commit. A repository can have any number
|
head is a pointer that points to any commit. A repository can have any number
|
||||||
of heads.
|
of heads.
|
||||||
|
|
||||||
### Stages of Git
|
### Stages of Git
|
||||||
* Modified - Changes have been made to a file but file has not been committed
|
* Modified - Changes have been made to a file but file has not been committed
|
||||||
to Git Database yet
|
to Git Database yet
|
||||||
* Staged - Marks a modified file to go into your next commit snapshot
|
* Staged - Marks a modified file to go into your next commit snapshot
|
||||||
* Committed - Files have been committed to the Git Database
|
* Committed - Files have been committed to the Git Database
|
||||||
@ -111,7 +111,7 @@ to Git Database yet
|
|||||||
|
|
||||||
### init
|
### init
|
||||||
|
|
||||||
Create an empty Git repository. The Git repository's settings, stored
|
Create an empty Git repository. The Git repository's settings, stored
|
||||||
information, and more is stored in a directory (a folder) named ".git".
|
information, and more is stored in a directory (a folder) named ".git".
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -179,7 +179,7 @@ $ git help status
|
|||||||
|
|
||||||
### add
|
### add
|
||||||
|
|
||||||
To add files to the staging area/index. If you do not `git add` new files to
|
To add files to the staging area/index. If you do not `git add` new files to
|
||||||
the staging area/index, they will not be included in commits!
|
the staging area/index, they will not be included in commits!
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -201,7 +201,7 @@ working directory/repo.
|
|||||||
|
|
||||||
### branch
|
### branch
|
||||||
|
|
||||||
Manage your branches. You can view, edit, create, delete branches using this
|
Manage your branches. You can view, edit, create, delete branches using this
|
||||||
command.
|
command.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -250,7 +250,7 @@ $ git push origin --tags
|
|||||||
|
|
||||||
### checkout
|
### checkout
|
||||||
|
|
||||||
Updates all files in the working tree to match the version in the index, or
|
Updates all files in the working tree to match the version in the index, or
|
||||||
specified tree.
|
specified tree.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -269,7 +269,7 @@ $ git checkout -b newBranch
|
|||||||
### clone
|
### clone
|
||||||
|
|
||||||
Clones, or copies, an existing repository into a new directory. It also adds
|
Clones, or copies, an existing repository into a new directory. It also adds
|
||||||
remote-tracking branches for each branch in the cloned repo, which allows you
|
remote-tracking branches for each branch in the cloned repo, which allows you
|
||||||
to push to a remote branch.
|
to push to a remote branch.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -285,7 +285,7 @@ $ git clone -b master-cn https://github.com/adambard/learnxinyminutes-docs.git -
|
|||||||
|
|
||||||
### commit
|
### commit
|
||||||
|
|
||||||
Stores the current contents of the index in a new "commit." This commit
|
Stores the current contents of the index in a new "commit." This commit
|
||||||
contains the changes made and a message created by the user.
|
contains the changes made and a message created by the user.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -401,11 +401,11 @@ Pulls from a repository and merges it with another branch.
|
|||||||
$ git pull origin master
|
$ git pull origin master
|
||||||
|
|
||||||
# By default, git pull will update your current branch
|
# By default, git pull will update your current branch
|
||||||
# by merging in new changes from its remote-tracking branch
|
# by merging in new changes from its remote-tracking branch
|
||||||
$ git pull
|
$ git pull
|
||||||
|
|
||||||
# Merge in changes from remote branch and rebase
|
# Merge in changes from remote branch and rebase
|
||||||
# branch commits onto your local repo, like: "git fetch <remote> <branch>, git
|
# branch commits onto your local repo, like: "git fetch <remote> <branch>, git
|
||||||
# rebase <remote>/<branch>"
|
# rebase <remote>/<branch>"
|
||||||
$ git pull origin master --rebase
|
$ git pull origin master --rebase
|
||||||
```
|
```
|
||||||
@ -421,7 +421,7 @@ Push and merge changes from a branch to a remote & branch.
|
|||||||
$ git push origin master
|
$ git push origin master
|
||||||
|
|
||||||
# By default, git push will push and merge changes from
|
# By default, git push will push and merge changes from
|
||||||
# the current branch to its remote-tracking branch
|
# the current branch to its remote-tracking branch
|
||||||
$ git push
|
$ git push
|
||||||
|
|
||||||
# To link up current local branch with a remote branch, add -u flag:
|
# To link up current local branch with a remote branch, add -u flag:
|
||||||
@ -432,7 +432,7 @@ $ git push
|
|||||||
|
|
||||||
### stash
|
### stash
|
||||||
|
|
||||||
Stashing takes the dirty state of your working directory and saves it on a
|
Stashing takes the dirty state of your working directory and saves it on a
|
||||||
stack of unfinished changes that you can reapply at any time.
|
stack of unfinished changes that you can reapply at any time.
|
||||||
|
|
||||||
Let's say you've been doing some work in your git repo, but you want to pull
|
Let's say you've been doing some work in your git repo, but you want to pull
|
||||||
@ -464,7 +464,7 @@ nothing to commit, working directory clean
|
|||||||
```
|
```
|
||||||
|
|
||||||
You can see what "hunks" you've stashed so far using `git stash list`.
|
You can see what "hunks" you've stashed so far using `git stash list`.
|
||||||
Since the "hunks" are stored in a Last-In-First-Out stack, our most recent
|
Since the "hunks" are stored in a Last-In-First-Out stack, our most recent
|
||||||
change will be at top.
|
change will be at top.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -495,7 +495,7 @@ Now you're ready to get back to work on your stuff!
|
|||||||
|
|
||||||
### rebase (caution)
|
### rebase (caution)
|
||||||
|
|
||||||
Take all changes that were committed on one branch, and replay them onto
|
Take all changes that were committed on one branch, and replay them onto
|
||||||
another branch.
|
another branch.
|
||||||
*Do not rebase commits that you have pushed to a public repo*.
|
*Do not rebase commits that you have pushed to a public repo*.
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ $ git rebase master experimentBranch
|
|||||||
### reset (caution)
|
### reset (caution)
|
||||||
|
|
||||||
Reset the current HEAD to the specified state. This allows you to undo merges,
|
Reset the current HEAD to the specified state. This allows you to undo merges,
|
||||||
pulls, commits, adds, and more. It's a great command but also dangerous if you
|
pulls, commits, adds, and more. It's a great command but also dangerous if you
|
||||||
don't know what you are doing.
|
don't know what you are doing.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -535,7 +535,7 @@ $ git reset --hard 31f2bb1
|
|||||||
Reflog will list most of the git commands you have done for a given time period,
|
Reflog will list most of the git commands you have done for a given time period,
|
||||||
default 90 days.
|
default 90 days.
|
||||||
|
|
||||||
This give you the chance to reverse any git commands that have gone wrong
|
This give you the chance to reverse any git commands that have gone wrong
|
||||||
(for instance, if a rebase has broken your application).
|
(for instance, if a rebase has broken your application).
|
||||||
|
|
||||||
You can do this:
|
You can do this:
|
||||||
@ -558,8 +558,8 @@ ed8ddf2 HEAD@{4}: rebase -i (pick): pythonstatcomp spanish translation (#1748)
|
|||||||
|
|
||||||
### revert
|
### revert
|
||||||
|
|
||||||
Revert can be used to undo a commit. It should not be confused with reset which
|
Revert can be used to undo a commit. It should not be confused with reset which
|
||||||
restores the state of a project to a previous point. Revert will add a new
|
restores the state of a project to a previous point. Revert will add a new
|
||||||
commit which is the inverse of the specified commit, thus reverting it.
|
commit which is the inverse of the specified commit, thus reverting it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -604,3 +604,5 @@ $ git rm /pather/to/the/file/HelloWorld.c
|
|||||||
* [Pro Git](http://www.git-scm.com/book/en/v2)
|
* [Pro Git](http://www.git-scm.com/book/en/v2)
|
||||||
|
|
||||||
* [An introduction to Git and GitHub for Beginners (Tutorial)](http://product.hubspot.com/blog/git-and-github-tutorial-for-beginners)
|
* [An introduction to Git and GitHub for Beginners (Tutorial)](http://product.hubspot.com/blog/git-and-github-tutorial-for-beginners)
|
||||||
|
|
||||||
|
* [The New Boston tutorial to Git covering basic commands and workflow](https://www.youtube.com/playlist?list=PL6gx4Cwl9DGAKWClAD_iKpNC0bGHxGhcx)
|
||||||
|
Loading…
Reference in New Issue
Block a user