git commonly used commands --- a local warehouse operation

Command: <> indicates an optional fill in [] represent the options must be filled in () represents an equivalent replacement for the () in content

1. Scratch related commands (the first three commands most commonly used)

git add [file] submitted a file to the staging area ([file] can be a file or directory name)

git add -A <path> commit all changes to the staging area, will be omitted <path>. FIG. (i.e., the current directory)

git add. Submit a new file and the file has been modified (not including the deleted files) to the staging area

git add -u <path> submission be modified and deleted files (not including the new file) to the staging area, omit <path>representation. (ie, the current directory)

git add -i <path>      View all being modified but not submitted or file has been deleted, and through it revert you can view sub-command <path> in all untracked files, and it will enter a sub-command system.

2. submit command (the first command the most used)
the commit -m git "message" in the local repository will "add" in the staging of the changes are committed, and add descriptive information in this message submitted
git commit -a "message" to modify or delete files to perform operations in the local repository has been tracking files are submitted, and add descriptive information in this message submitted
git commit -am "message" on behalf of -a and -m command role takes effect
git commit -v show unity differences between the HEAD content has been submitted and this will be submitted to the occurrence of which help the user to change the description submitted.
git commit --amend enter vim, you can change the description of the information submitted by the last save
--amend the commit -m git "updated last message" to change the description of the last commit replaced with updated last message and save
3. The revocation modify / add / commit

(1) in the revocation code is modified workspace

git checkout - [file] to discard a file this revision

git checkout -. all discarded

 Note: git checkout - all discarded, including: new files are deleted, deleted files will be restored back, the modified file will go back. Some say this premise is back to what it was before staging area. Have any impact on the code before you save it in a temporary area where not. Code commit to submit to the local branch did not even affect the

(2) Code git add to the buffer zone, did not commit the

git reset HEAD [file] to discard a file of this staging
git reset HEAD. discard all

(3) git commit to the local branch

git reset <Options> HEAD-1 (HEAD ^) returns to the last submitted version

              Options:

              --mixed (the default parameters, and do not write the same effect) does not delete a workspace change the code, the revocation of commit, and the revocation git add. Operation

             --soft not delete a workspace change the code, revocation commit, not revoked git add. 

            --head   delete a workspace change the code, revocation commit, undo git add. (That is restored to the last commit state)

 

 

Guess you like

Origin www.cnblogs.com/jest549/p/11479941.html