- 浏览: 596391 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
月光杯:
问题解决了吗?
Exceptions in HDFS -
iostreamin:
神,好厉害,这是我找到的唯一可以ac的Java代码,厉害。
[leetcode] word ladder II -
standalone:
One answer I agree with:引用Whene ...
How many string objects are created? -
DiaoCow:
不错!,一开始对这些确实容易犯迷糊
erlang中的冒号 分号 和 句号 -
standalone:
Exception in thread "main& ...
one java interview question
1. git init
Create a new repo with exsiting project.
2. git diff
This command compares what's in your working directory with what's in your staging area. The result tells what changes have not been staged.
3. git diff --cached
Shows what you've stage that will go into your next commit. In Git v1.6 or later, you can use git diff --staged.
4. git comit -a -m 'comment'
skip staging area. You do not need run git add before you commit.
5. git rm
Reimoves the file from your working directory and you don't see it as an untracked file next time.
6. git rm --cached
Remove the file from Git but keep it on your hard disk.
7. git mv file_a file_b
8. git log -p -2
This example shows last two commit log. -p shows diff introduced in each commit.
9. git log --pretyy=format:"%h %s" --graph
shows branch and merge history. More options:
Option Description of Output
%H Commit hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author e-mail
%ad Author date (format respects the –date= option)
%ar Author date, relative
%cn Committer name
%ce Committer email
%cd Committer date
%cr Committer date, relative
%s Subject
10. git commit --amend
You can redo your last commit. This can be useful when you forgot to git add some files or you want to edit your commit message.
11. git reset HEAD
Change file to unstage.
12. git checkout -- filename
This discards your current changes. It looks like when you last committed.
13. git remote add shortname remote_repo
This command adds a remote repo. git remote -v shows your current remote repo.
14. git fetch shortname
This fetches all information you don't have in your repo but in shortname. After this, you have all refs to all branches from that remote. you can run git merge shortname/master to merge it into your master branch.
Notify git fetch pulls all new commit to your working directory but does not automatically merge it.
15. git pull
This fetches data and merges.
16. git push [remote-name] [branch-name]
E.g., "git push origin master" pushes your master branch to origin repo.
17. To be continued...
评论
Figure 3-31. A history with a topic branch off another topic branch.
Suppose you decide that you want to merge your client-side changes into your mainline for a release, but you want to hold off on the server-side changes until it’s tested further. You can take the changes on client that aren’t on server (C8 and C9) and replay them on your master branch by using the --onto option of git rebase:
$ git rebase --onto master server client
This basically says, “Check out the client branch, figure out the patches from the common ancestor of the client and server branches, and then replay them onto master.” It’s a bit complex; but the result, shown in Figure 3-32, is pretty cool.
从git里面去除但是保留在磁盘上;
2. git rm
删除文件并从git里面去除;
3. git reset HEAD
back到unstaged状态;
4. git checkout -- file
丢弃修改,返回到上次commit的样子。
所以
如果你要放弃修改,回到干净的上次commit的版本,只能用第四个;
如果你git add了一个文件,现在反悔了,那么用第三个可以撤销,不会影响你的更改;
如果你自己的一个test文件误加进了git,你只希望从git里面拿掉,但不希望从磁盘上删除,用第一个;
如果你根本不想要这个文件了,那么用git rm吧。
不知道上面总结的对不对。
发表评论
-
一个命令创建多个目录
2013-06-13 12:36 889可能我太土了,才发现下面这个命令! mkdir -p src ... -
use "--links" option of rsync
2013-05-23 10:45 724Today I used rsync to copy some ... -
Makefile tutorial
2013-01-07 14:30 889Old but good. http://www.codep ... -
crontab定期执行命令详解,以及实例
2012-12-18 17:29 917使用时可以参考这个博客: http://blog.51yip ... -
vim tips
2012-07-04 13:59 939I read some articles about vim ... -
cvs不能更新文件的权限
2012-06-28 13:07 1071一个project用到了古老的cvs管理源代码。 一个文件我c ... -
GNU Make Variables: simple and recursive
2012-04-19 14:17 1025今天有时间看了一下teammate写的makefile,学习了 ... -
How do I find the largest top 10 files in linux?
2012-04-06 15:24 1106http://www.cyberciti.biz/faq/ho ... -
xargs usage with multi arguments
2011-11-30 12:24 603http://offbytwo.com/2011/06/26/ ... -
how to explain free buffers and cached memory usage
2011-07-18 11:57 1249free -m tota ... -
"error in locking authority file .Xauthority
2011-01-11 11:34 2818今天在windows上vncviewer连linux机器的时候 ... -
raid 0 vs. raid1
2010-12-30 10:20 1344RAID 0 (block-level striping ... -
hwo to configure linux vncserver
2010-12-24 14:10 840http://bobpeers.com/linux/vnc -
set cpu performance mode
2010-11-15 14:38 1846A cheap/dirty little hack to in ... -
Ten Amazing Linux Commands
2010-11-08 22:42 887sudo !! 以 root 帐户执行上一条命令。 ... -
awk code
2010-10-26 17:53 912netstat -n | awk '/^tcp/ {++S ... -
Queue sysfs files
2010-07-28 13:50 1039Based on kernel version 2.6.34. ... -
Install blktrace
2010-07-27 13:15 1418I use libaio-0.3.106.tar.gz and ... -
awk使用实例
2010-02-09 15:47 2051awk使用实例(转载) 2009-08-25 16:41 ... -
vim的一个问题
2010-01-12 11:08 1935E575: viminfo: Illegal starting ...
相关推荐
progit中文版 本章介绍开始使用 Git 前的相关知识。我们会先了解一些版本控制工具的历史背景,然后试着在你的系统上把 Git 跑起来,直到最后配置好,可以开始正常的开发工作。读完本章,你就会理解为什么 Git 会...
ProGit-zh git 教程 个人收集电子书,仅用学习使用,不可用于商业用途,如有版权问题,请联系删除!
学习git不可多得的好文档。把这个看会了,用熟了,你就无敌了!!!
progit英文版第二版,git里的圣经,学习和使用git的都建议看看。
Git教程progit的中文版,学习Git工具必备。本文档将网站 http://git.oschina.net/progit 的内容打包成chm,方便离线阅读。
progit-zh git官方文档-中文版
git官方中文文档 https://git-scm.com/book/zh/v2/ 亦可自行下载,亦可支持我一下
progit第二版中文版 kindle格式 ----- 第一版出版到现在已经过去了四年。到今天,Git 虽然出现了许多改变,但是还有很多重要的事情一如昨日。因为 Git 核心团队对保持向后兼容性异常固执,所以直到今天大多数核心...
pro git 电子书 pro git 电子书 pro git 电子书 pro git 电子书 pro git 电子书 pro git 电子书 pro git 电子书
word文档形式的progit中文版, 来源于http://progit.org/book/zh
pro git 中文版
Pro Git This is the PDF file for the Pro Git book contents. It is licensed under the Creative Commons Attribution-Non Commercial-Share Alike 3.0 license.
本想免费,但是没找到免费方法,可以自行下载 https://github.com/progit/progit2-zh/releases/download/2.1.9/progit_v2.1.9.pdf
Pro Git中文版,已经整理了完整的目录
PRO GIT, english version
《Pro Git》这本书 [在线版本(第一版)](http://iissnan.com/progit)的整理而成的md档,适合快速了解Git版本控制原理的人员。
Pro Git(中文版 )2014 支持 iBook
Pro git中文版本,是电子书籍。Pro git中文版本,是电子书籍。
《Pro Git》主要介绍了Git使用基础和原理,适合Git爱好者和初学者参考。
Pro Git》中文版. git一本比较全面的介绍了使用方法,学习GIT必备书籍