Git操作备忘

修改file1.txt后,

$git status

显示file1有改动,如果不想要刚才的改动。

$ git checkout  -- file1.txt

file1恢复到改动之前。

如果想保留刚才的改动,再次 git add file1.txt, 然后  git commit -m "..........................."


$ git diff readme.txt 
修改内容后,查看改动内容

$ git log
查看每次提交

$ git log --pretty=oneline
3628164fb26d48395383f8f31179f24e0882e1e0 append GPL
ea34578d5496d7dd233c827ed32a8cd576c5ee85 add distributed
cb926e7ea50ad11b8f9e909c05226233bf755030 wrote a readme file
$ git reset --hard HEAD^
HEAD is now at ea34578 add distributed

上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。

******http://www.git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History******

$ git log

$ git log -p -2

$ git log -U1 --word-diff

$ git log -U1 -p -2 --word-diff

$ git log --stat

$ git log --pretty=oneline

$ git log --pretty=format:"%h - %an, %ar : %s"

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
$ git log --pretty=format:"%h %s" --graph

Option Description
-p Show the patch introduced with each commit.
--word-diff Show the patch in a word diff format.
--stat Show statistics for files modified in each commit.
--shortstat Display only the changed/insertions/deletions line from the --stat command.
--name-only Show the list of files modified after the commit information.
--name-status Show the list of files affected with added/modified/deleted information as well.
--abbrev-commit Show only the first few characters of the SHA-1 checksum instead of all 40.
--relative-date Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.
--graph Display an ASCII graph of the branch and merge history beside the log output.
--pretty Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).
--oneline A convenience option short for --pretty=oneline --abbrev-commit.
*************http://www.git-scm.com/book/en/Git-Basics-Undoing-Things*****************

$ git commit -m 'initial commit'

$ git add forgotten_file

$ git commit --amend

****************http://www.git-scm.com/book/en/Git-Basics-Working-with-Remotes********************

$ git remote

$ git remote -v

$ git remote add pb git://github.com/paulboone/ticgit.git

$ git fetch [remote-name]

$ git push origin master

$ git remote rename pb paul

$ git remote rm paul

****************http://www.git-scm.com/book/en/Git-Basics-Tagging************************

$ git tag

$ git tag -l 'v1.4.2.*'

$ git tag -a v1.4 -m 'my version 1.4'

*********************http://www.git-scm.com/book/en/Git-Branching-What-a-Branch-Is*********************

Staging the files checksums each one (the SHA-1 hash we mentioned in Chapter 1), stores that version of the file in the Git repository (Git refers to them as blobs), and adds that checksum to the staging area:


$ git branch testing

$ git checkout testing

$ git checkout -b iss53

Switched to a new branch 'iss53'



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值