git tutorial return to the past, contrast version

Back to back

git reset command options

1.git reset --mixed HEAD ~ (default)

- Mobile HEAD pointing, pointing to a snapshot that will last

- HEAD will move after the snapshot pointed to roll back to the staging area

2.git reset --soft HEAD~

- moving HEAD point to point on a snapshot (corresponding to withdraw commit)

3.git reset --hard HEAD~

- Mobile HEAD pointing, pointing to a snapshot that will last

- HEAD will move after the snapshot pointed to roll back to the staging area

- the staging area to restore files to a working directory

 

 

reset roll back to a specific snapshot

git reset id number (recommended is 5)

When restoring to the oldest id, if you know the latest id can roll back to the most recent snapshot, even though he has been covered by the old version (hard)

 

reset roll back individual files

git reset snapshot version of the file name / path (ignoring HEAD pointer to change)

 

Compare Editions

1. Comparison of the staging area and the local working directory

git diff

the diff - Git A / . the README MD     B / . the README MD 
# represents the distribution of the temporary files and directories in the working directory is placed automatically generated a / b folder, folders compare two --- A / the README . md # staging area +++ b / the README. md # working directory of the new (+) search # / + keyword search down from #? + keyword search from the bottom up q to quit







Comparison of two historical snapshots:

git diff snapshot snapshot ID1 ID2

 

Snapshot comparisons staging area, and git repository

git diff --cached snapshot id

Modify the last commit

1. In the actual development process, you may encounter the following two scenarios:

Scenario 1: version soon submit (commit) to the warehouse, suddenly remembered that two documents had not been missed (add)

Scenario 2: version soon submit (commit) to the warehouse, suddenly remembered Imprint write is not comprehensive enough, you can not demonstrate the weight of the revision of the great significance

 

commit to perform with --amemd option of submitting command, Git will '' correct '' a recent submission

git commit --amend

Delete Files

git rm filename

This command deletes only the working directory and file staging area, that is, cancel tracking, the next time the submission is not versioned.

Then go back soft HEAD

 

Rename the file

old git mv file name new file name

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/pythonyeyu/p/10951151.html
Recommended