Git操作备忘

来源:互联网 发布:阿里云升级配置后 编辑:程序博客网 时间:2024/05/22 00:55

修改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=oneline3628164fb26d48395383f8f31179f24e0882e1e0 append GPLea34578d5496d7dd233c827ed32a8cd576c5ee85 add distributedcb926e7ea50ad11b8f9e909c05226233bf755030 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"

OptionDescription of Output%HCommit hash%hAbbreviated commit hash%TTree hash%tAbbreviated tree hash%PParent hashes%pAbbreviated parent hashes%anAuthor name%aeAuthor e-mail%adAuthor date (format respects the --date= option)%arAuthor date, relative%cnCommitter name%ceCommitter email%cdCommitter date%crCommitter date, relative%sSubject$ git log --pretty=format:"%h %s" --graph

OptionDescription-pShow the patch introduced with each commit.--word-diffShow the patch in a word diff format.--statShow statistics for files modified in each commit.--shortstatDisplay only the changed/insertions/deletions line from the --stat command.--name-onlyShow the list of files modified after the commit information.--name-statusShow the list of files affected with added/modified/deleted information as well.--abbrev-commitShow only the first few characters of the SHA-1 checksum instead of all 40.--relative-dateDisplay the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.--graphDisplay an ASCII graph of the branch and merge history beside the log output.--prettyShow commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).--onelineA 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
原创粉丝点击