Git User's Manual (for version 1.5.3 or newer)
______________________________________________
Git is a fast distributed revision control system.
This manual is designed to be readable by someone with basic UNIX
command-line skills, but no previous knowledge of Git.
<<repositories-and-branches>> and <<exploring-git-history>> explain how
to fetch and study a project using git--read these chapters to learn how
to build and test a particular version of a software project, search for
regressions, and so on.
People needing to do actual development will also want to read
<<Developing-With-git>> and <<sharing-development>>.
Further chapters cover more specialized topics.
Comprehensive reference documentation is available through the man
pages, or linkgit:git-help[1] command. For example, for the command
`git clone <repo>`, you can either use:
------------------------------------------------
$ man git-clone
------------------------------------------------
or:
------------------------------------------------
$ git help clone
------------------------------------------------
With the latter, you can use the manual viewer of your choice; see
linkgit:git-help[1] for more information.
See also <<git-quick-start>> for a brief overview of Git commands,
without any explanation.
Finally, see <<todo>> for ways that you can help make this manual more
complete.
[[repositories-and-branches]]
Repositories and Branches
=========================
[[how-to-get-a-git-repository]]
How to get a Git repository
---------------------------
It will be useful to have a Git repository to experiment with as you
read this manual.
The best way to get one is by using the linkgit:git-clone[1] command to
download a copy of an existing repository. If you don't already have a
project in mind, here are some interesting examples:
------------------------------------------------
# Git itself (approx. 10MB download):
$ git clone git://git.kernel.org/pub/scm/git/git.git
# the Linux kernel (approx. 150MB download):
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
------------------------------------------------
The initial clone may be time-consuming for a large project, but you
will only need to clone once.
The clone command creates a new directory named after the project (`git`
or `linux-2.6` in the examples above). After you cd into this
directory, you will see that it contains a copy of the project files,
called the <<def_working_tree,working tree>>, together with a special
top-level directory named `.git`, which contains all the information
about the history of the project.
[[how-to-check-out]]
How to check out a different version of a project
-------------------------------------------------
Git is best thought of as a tool for storing the history of a collection
of files. It stores the history as a compressed collection of
interrelated snapshots of the project's contents. In Git each such
version is called a <<def_commit,commit>>.
Those snapshots aren't necessarily all arranged in a single line from
oldest to newest; instead, work may simultaneously proceed along
parallel lines of development, called <<def_branch,branches>>, which may
merge and diverge.
A single Git repository can track development on multiple branches. It
does this by keeping a list of <<def_head,heads>> which reference the
latest commit on each branch; the linkgit:git-branch[1] command shows
you the list of branch heads:
------------------------------------------------
$ git branch
* master
------------------------------------------------
A freshly cloned repository contains a single branch head, by default
named "master", with the working directory initialized to the state of
the project referred to by that branch head.
Most projects also use <<def_tag,tags>>. Tags, like heads, are
references into the project's history, and can be listed using the
linkgit:git-tag[1] command:
------------------------------------------------
$ git tag -l
v2.6.11
v2.6.11-tree
v2.6.12
v2.6.12-rc2
v2.6.12-rc3
v2.6.12-rc4
v2.6.12-rc5
v2.6.12-rc6
v2.6.13
...
------------------------------------------------
Tags are expected to always point at the same version of a project,
while heads are expected to advance as development progresses.
Create a new branch head pointing to one of these versions and check it
out using linkgit:git-checkout[1]:
------------------------------------------------
$ git checkout -b new v2.6.13
------------------------------------------------
The working directory then reflects the contents that the project had
when it was tagged v2.6.13, and linkgit:git-branch[1] shows two
branches, with an asterisk marking the currently checked-out branch:
------------------------------------------------
$ git branch
master
* new
------------------------------------------------
If you decide that you'd rather see version 2.6.17, you can modify
the current branch to point at v2.6.17 instead, with
------------------------------------------------
$ git reset --hard v2.6.17
------------------------------------------------
Note that if the current branch head was your only reference to a
particular point in history, then resetting that branch may leave you
with no way to find the history it used to point to; so use this command
carefully.
[[understanding-commits]]
Understanding History: Commits
------------------------------
Every change in the history of a project is represented by a commit.
The linkgit:git-show[1] command shows the most recent commit on the
current branch:
------------------------------------------------
$ git show
commit 17cf781661e6d38f737f15f53ab552f1e95960d7
Author: Linus Torvalds <torvalds@ppc970.osdl.org.(none)>
Date: Tue Apr 19 14:11:06 2005 -0700
Remove duplicate getenv(DB_ENVIRONMENT) call
Noted by Tony Luck.
diff --git a/init-db.c b/init-db.c
index 65898fa..b002dc6 100644
--- a/init-db.c
+++ b/init-db.c
@@ -7,7 +7,7 @@
int main(int argc, char **argv)
{
- char *sha1_dir = getenv(DB_ENVIRONMENT), *path;
+ char *sha1_dir, *path;
int len, i;
if (mkdir(".git", 0755) < 0) {
------------------------------------------------
As you can see, a commit shows who made the latest change, what they
did, and why.
Every commit has a 40-hexdigit id, sometimes called the "object name" or the
"SHA-1 id", shown on the first line of the `git show` output. You can usually
refer to a commit by a shorter name, such as a tag or a branch name, but this
longer name can also be useful. Most importantly, it is a globally unique
name for this commit: so if you tell somebody else the object name (for
example in email), then you are guaranteed that name will refer to the same
commit in their repository that it does in yours (assuming their repository
has that commit at all). Since the object name is computed as a hash over the
contents of the commit, you are guaranteed that the commit can never change
without its name also changing.
In fact, in <<git-concepts>> we shall see that everything stored in Git
history, including file data and directory contents, is stored in an object
with a name that is a hash of its contents.
[[understanding-reachability]]
Understanding history: commits, parents, and reachability
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Every commit (except the very first commit in a project) also has a
parent commit which shows what happened before this commit.
Following the chain of parents will eventually take you back to the
beginning of the project.
However, the commits do not form a simple list; Git allows lines of
development to diverge and then reconverge, and the point where two
lines of development reconverge is called a "merge". The commit
representing a merge can therefore have more than one parent, with
each parent representing the most recent commit on one of the lines
of development leading to that point.
The best way to see how this works is using the linkgit:gitk[1]
command; running gitk
没有合适的资源?快使用搜索试试~ 我知道了~
git-1.8.2.3.tar.gz
5星 · 超过95%的资源 需积分: 10 256 下载量 147 浏览量
2015-05-05
19:42:32
上传
评论
收藏 4.2MB GZ 举报
温馨提示
共2569个文件
sh:734个
txt:468个
c:333个
Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。
资源推荐
资源详情
资源评论
收起资源包目录
git-1.8.2.3.tar.gz (2569个子文件)
diff.0-1 49B
diff.0-2 77B
diff.0-3 80B
LGPL-2.1 26KB
diff.1-0 49B
diff.1-2 80B
diff.1-3 80B
15045f6ce8ff75747562173640456a394412c8 34B
16d5255855ac160652ee5253b06cd8ee14165a 116B
diff.2-0 77B
diff.2-1 80B
diff.2-3 77B
diff.3-0 80B
diff.3-1 80B
diff.3-2 77B
37b887a73791d12d26c0d3e39568a8fb0fa6e8 54B
4e360d6c70fbd72411991c02a09c442cf7a9fa 156B
56f9233d999f61ef23ef390b9c71d75399f435 17B
65efe2a145dda7ee51d1741299f848e5bf752e 10B
72a6b2c4a577ab0338860fa9fe87f761fc9bbd 18B
75c6237d3fcdd0ac2f0decc7d3fa6a50b66c09 139B
7cc5642cb1a054f08cc83f2d943e56fd3ebe99 19B
9cedb5c46929d18e0f118e9fa31927487af3b6 117B
9de29bb2d1d6434b8b29ae775ad8c2e48c5391 9B
a,v 2KB
a,v 589B
configure.ac 32KB
add-comments 88B
add-content 47B
add-content-and-comment 73B
add-signed-off 63B
add-whitespaced-content 76B
aee0540ea990d9761a3eb9ab183003a71c3696 181B
am-test-1-1 312B
am-test-1-2 315B
am-test-2-1 330B
am-test-2-2 333B
am-test-3-1 350B
am-test-3-2 340B
am-test-4-1 354B
am-test-4-2 388B
am-test-5-1 308B
am-test-5-2 287B
am-test-6-1 266B
araxis 392B
b,v 703B
b1625de3ba8b2214d1e0d0591138aea733f64f 252B
git-completion.bash 55KB
bc3 401B
refs.br-branches-default 771B
fetch.br-branches-default 560B
refs.br-branches-default-merge 771B
fetch.br-branches-default-merge 643B
refs.br-branches-default-merge_branches-default 771B
fetch.br-branches-default-merge_branches-default 660B
refs.br-branches-default-octopus 771B
fetch.br-branches-default-octopus 705B
refs.br-branches-default-octopus_branches-default 771B
fetch.br-branches-default-octopus_branches-default 722B
refs.br-branches-default_branches-default 771B
fetch.br-branches-default_branches-default 577B
refs.br-branches-one 767B
fetch.br-branches-one 553B
refs.br-branches-one-merge 767B
fetch.br-branches-one-merge 636B
refs.br-branches-one-merge_branches-one 767B
fetch.br-branches-one-merge_branches-one 649B
refs.br-branches-one-octopus 767B
fetch.br-branches-one-octopus 623B
refs.br-branches-one-octopus_branches-one 767B
fetch.br-branches-one-octopus_branches-one 636B
refs.br-branches-one_branches-one 767B
fetch.br-branches-one_branches-one 566B
refs.br-config-explicit 955B
fetch.br-config-explicit 786B
refs.br-config-explicit-merge 955B
fetch.br-config-explicit-merge 792B
refs.br-config-explicit-merge_config-explicit 955B
fetch.br-config-explicit-merge_config-explicit 808B
refs.br-config-explicit-octopus 955B
fetch.br-config-explicit-octopus 781B
refs.br-config-explicit-octopus_config-explicit 955B
fetch.br-config-explicit-octopus_config-explicit 797B
refs.br-config-explicit_config-explicit 955B
fetch.br-config-explicit_config-explicit 802B
refs.br-config-glob 955B
fetch.br-config-glob 795B
refs.br-config-glob-merge 955B
fetch.br-config-glob-merge 788B
refs.br-config-glob-merge_config-glob 955B
fetch.br-config-glob-merge_config-glob 800B
refs.br-config-glob-octopus 955B
fetch.br-config-glob-octopus 777B
refs.br-config-glob-octopus_config-glob 955B
fetch.br-config-glob-octopus_config-glob 789B
refs.br-config-glob_config-glob 955B
fetch.br-config-glob_config-glob 807B
refs.br-remote-explicit 955B
fetch.br-remote-explicit 786B
refs.br-remote-explicit-merge 955B
共 2569 条
- 1
- 2
- 3
- 4
- 5
- 6
- 26
qq_27355381
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页