git 入门
2015-06-12 13:00
197 查看
http://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to-understand-git/
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可以用
a Modified File可以用
19.
22.git fetch默认会获取repo所有branch的进度,除非指定哪个branch。git push可以将某个branch push到repo中去。
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中去。
相关文章推荐
- LeetCode 9 Palindrome Number
- 堆和栈的区别
- [扩展欧几里得定理]青蛙的约会
- Quartz 入门例子
- javax.faces.view.facelets.ResourceResolver
- bzoj 1015: [JSOI2008]星球大战starwar 并查集
- SA读书笔记1
- cxgrid全选
- IOS菜鸟的所感所思(十一)——统计文本中单词出现的次数并按照次数高低排序
- 在Gridview如何进行每行单元格比较
- openwrt上使用openssl对文件加密
- POJ-2774
- 一张图让你理清渗透思路
- 配置php和apache结合,测试php
- 仿iOS图标抖动
- 蓝牙通讯神器
- 关于android touch事件的传递问题
- Linux3.10内核之后proc文件系统的使用
- Dal介绍2:自动分页功能
- SIFT