-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial
gittutorial - 一个介绍Git的教程
git *
这个教程解释了怎样将一个新的项目导入到Git,进行更改,和分享更改给其他的开发者。
如果你首先对使用git拉取一个项目感兴趣,例如:体验最新的版本,你可能更加喜欢从The Git User's Manual //TODO 的前两章开始。
首先,注意你可以使用命令获取记录文档,比如:git log --graph,通过一下命令获取命令帮助:
$ man git-log
or:
$ git help log
稍后,你可以使用这个手册阅读你需要的部分;查看git-help // TODO 获取更多信息。
这是一个好主意,向Git介绍你自己,使用你的名称和公开邮箱在做任何操作之前。最简单的操作方式是:
$ git config --global user.name "Your Name Comes Here"
$ git config --global user.email you@yourdomain.example.com
假设你有一个原始的包project.tar.gz用来初始化你的工作。你可以这样将它放在Git版本下。
$ tar xzf project.tar.gz
$ cd project
$ git init
Git将返回
Initialized empty Git repository in .git/
你现在已经初始了工作目录-你可以注意到一个新的目录被创建了,叫做".git"。
下一步,告诉Git在当前目录下建立所有文件的快照(注意"."),使用git add:
$ git add .
这个快照现在存储在一个临时的区域,Git叫它"index"。你可以使用git commit永久存储这个index的内容在仓库中。
$ git commit
这里将提示你填写提交的描述信息。现在你已经在Git上存储了你项目的第一个版本。
更新一些文件,然后将他们更新的内容添加到index:
$ git add file1 file2 file3
你现在已经准备好了要提交的内容。你可以使用git diff命令和--cached选项看见关于要提交的内容
$ git diff -cached
(不使用--cached,git diff 将展示给你已经发生但是还没有加入到index中的变更),你也可以获取当前情况的简单总结使用git status:
$ git status
On branch master
Changes to be committed:
Your branch is up to date with 'origin/master'
(use "git restore --staged <file>..." to unstage)
modified: file1
modified: file2
modified: file3
如果未来你需要任何调整,现在这样做,然后加入任何新的更改到index。最后提交你的改变。
$ git commmit
这将再一次提示你填写信息描述你的改变,然后会对你的项目记录一个新的版本。
或者,替代事先使用git add,你可以使用
$ git commit -a
你可以注意到,任何改变的文件(除了新的文件),被加入到了index,然后提交,都在一步完成。 提交信息的注意点:尽管不是必要的,但使用简短的一行(少于50个字符)总结这次改变作为提交信息的开始是一个好主意,随后是一个空行,然后是详尽的描述。在一次提交信息中,文本会把从开头到第一个空行的内容作为提交标题,并且这个标题从始至终都会被贯彻到Git的使用中。例如,git-format-patch[1] //TODO 将一个提交发送到邮箱,并且使用标题作为主题行,其他的提交内容作为邮箱内容。
thank you!
git
config
help
bugreport
init
clone
add
status
diff
commit
notes
restore
reset
rm
mv
branch
checkout
switch
merge
mergetool
log
stash
tag
worktree
fetch
pull
push
remote
submodule
show
log
diff
difftool
range-diff
shortlog
describe
apply
cherry-pick
diff
rebase
revert
bisect
blame
grep
gitattributes
Command-line interface conventions
Everyday Git
Frequently Asked Questions (FAQ)
Glossary
Hooks
gitignore
gitmodules
Revisions
Submodules
Tutorial
Workflows
All guides...