见过最好的git入门教程

今天找到一篇见过最好的git入门教程git

http://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to-understand-git/工具

 

粘帖一些命令fetch

1. git add 添加文件到staged area.
2. git commit 会commit staged file ,有几个选项比较重要:-a 跳过staged area,直接commit,后面加文件名也会使那个文件跳过stage,直接commit。可是前提是文件已经在index中了,新文件不会自动加入。
3.git status 查看从上次commit到目前的变化,git diff会更详细,可是它只包含应该要包含在staged area中却还未包含进去的变化,git diff --staged则列出来从上次commit到staged area的变化。
4. .gitignore文件能够设置哪些文件被排除进去,一般能够设.o, .a等文件。
5. git rm 用来remove文件。
6. git mv能够用来重命名文件。
7. git log用来查看日志,git log -p查看详细,gitk 是个图形化的查看工具。
8.Unstaging a Staged File能够用git reset HEAD <file>。 Unmodifying a Modified File能够用git checkout -- <file>。 git commit --amend用来取消上次的commit。
9. git remote显示全部的remote(加-v显示详细信息)。
 git remote add [shortname] [url]用来添加remote。 git fetch [remote-name]只会pull下来所有的更动,但不会自动merge,可是git pull会自动merge。 git remote show [remote-name]能够看到一个remote的详细信息。 git remote rename用来改变一个remote的名字。 git remote rm删除一个remote。
10.git tag列出全部的tag。git show tag-name能够查看tag详细信息。git tag [-a] tag-name -m message [commit-checksum]若是有-a 就添加一个annotated tag,若是没有-a,就添加一个lightweight tag,若是后面要在某个commit以后添加一个tag,就加上checksum好了。 git push有个选项 --tags会把tags信息也push上去。

11.
 git branch testing添加一个testing的branch. git checkout testing切换到testing branch. 
12. 切换branch的时候,当前的branch不能有和要切换过去的branch冲突的uncommitted changes.
13. git merge branch-name 将branch-name merge到当前branch.若是有conflict,能够用status查看状态,解决conflict以后用add 通知git已经解决。而后用commit commit the merge。
14.
   git branch -d branch-name,可是这个branch必须被所有merge到HEAD中了。若是选项是-D的化,就无论它的merge status了。
15. git branch --merged只显示被HEAD彻底包含的branch,--no-merged只显示没被HEAD彻底包含的branch。
16.
 git push (remote) (branch)把本地某个branch push到remote上去。 git push (remote) (local-branch-name):(remote-branch-name)能够把本地branch push到remote branch上去。
17.git fetch 下载下来的branch不能edit,必需要手动merge到本地branch以后才能够edit。
   $ git checkout -b local-branch-name remote-name/remote-branch-name 能够把server上的branch下载下来,而且能够直接edit。
18.
 Tracking Branches里面能够没必要在pull和push后面加remote参数。git branch -r列出remote tracking branches.
19. git push [remotename] :[remote-branch]删除掉某个remote branch。
20. rebase能够得到和merge同样的效果,可是log记录更好,由于看起来没有分支。
 git rebase --onto newbase upstream branch会把从upstream到branch的改动rebase到newbase上去。git rebase basebranch topicbranch会把topicbranch rebase到basebranch上。
21. 
Do not rebase commits that you have pushed to a public repository.

22.git fetch默认会获取repo全部branch的进度,除非指定哪一个branch。git push能够将某个branch push到repo中去。
url

相关文章
相关标签/搜索