Common usage instructions and git

Create a git repository

  Command: git init
  Description: create a resource that can accommodate (object) of the container (warehouse)

To the staging area next to the warehouse to store objects (resources)

  Command: git add [filename]
  Description: The file resource (object) to the container (warehouse) administrator (staging area), said after the resource (object) to the container (warehouse) of;

The object (resource) in the staging area to the warehouse store

  Command: git commit -m [Comment this submission]
  Description: Tell container (warehouse) to change the status of all of the previous resource (object) conducted a snapshot (photo camera picture); and resource files (objects) to container (warehouse) administrator (staging area), said after the resource (object) to the container (warehouse) of;

To warehouse to store objects (resources)

  Command: git diff "filename"
  Description: The current modified file resource (object) file container resources (warehouse) in (object) of the comparison

View container (warehouse) submission history

  Command: git log / git log --pretty = online git log --graph
  Description: Submit View the history of git

git fall back to the specified version (Time Machine)

  Command: git reset --hard [commit_id]
  Description: Submit View the history of git's
  Note: git in the world: HEAD represents the current version, the previous version on behalf of the previous version HEAD ^^ representatives HEAD ^ HEAD ~ 100 representatives on 100 version; git reset HEAD "filename" can modify the staging area off of revocation (unstage) back into the work area

git View command history

  Command: git reflog
  Description: View the history of command in order to confirm that you want to return to that future versions

git withdraw modification

  Command: git checkout [filename]
  Description: modify the corresponding file in the work area complete withdrawal
  Note:
Scene One: The corresponding document has not been modified into temporary storage area; undo changes and will return to exactly the same repository status
scene two: after modifying the corresponding file into the staging area, once again has been modified; undo changes will be added back to the state after staging area
summary: let the file back to the last time when git add or git commit status

git delete files

  Command: git rm [filename]
  Description: Removes the corresponding file from the repository, files and workspaces are also deleted

Remote repository

List remote library already exists

  Command: git remote
  Description: Lists the remote library already exists

List remote library already exists

  Command: git remote -v / git remote --verbose
  Description: For more information about the remote repository already existing list; list its remote URL behind each name

Adding a remote repository

  Command: git remote add [remote library name] [URL]
  Description: remote library name is a reference to the remote database (which is the name represents the URL points to a remote database),

Modify a remote repository

  Command: git remote rename [original name] [target name]
  Description: Original name soon changed to target name

Modify a remote repository

  Command: git remote rm [remote library name]
  Description: Removes the specified name of the remote library

Branch Management

Create and switch to the corresponding branch

  Command: git checkout -b [branch]
  on and switch to create a branch is created branches: Description

Creating a branch

  Command: git branch [branch]
  Description: create a branch

Remote library to a good start and then pulled to the local branch

  Command: git checkout -b [branch] [remote library] / [branch]
  Description: The remote library has been pulled to open a good local branch

Local first good start and then pushed to the remote branch

  Command: git checkout -b [branch] (creating a branch) git push [remote repository] [local branch name]: [remote library branch name]
  Description: remote library has been opened to pull a good local branch

Switching branch

  Command: git checkout [branch]
  Description: to switch on the corresponding branch

View all branches

  Command: git branch / git branch -r (View all remote branch)
  Description: View All branches
Note: The current front branch will mark a number *

Merge branch

  Command: git merge [branch]
  Description: The contents of the corresponding branch merged into the master
NOTE:
Merge if "Fast forward" prompt appears; in this scenario except that Git master branch pointer directly to the right; if you do not use. " add descriptive information when merge "[branch name]:; Fast forward" git merge --no-ff -m eg policy can be changed to general policy parameters using the --no-ff in the merge "
after" Fast forward "policy merge once I did not see the merger; general strategy can

Deleted branches

  Command: git branch -d [branch name] / git branch -D [branch] (force deletion)
  Description: Deletes branch

stash (data storage)

The current work site stored
  command: git stash
  Description: The current work site stored, and so continue to work after the scene after recovery

Display the list of work-site storage

  Command: git stash list
  Description: View the current list of your saved workspace

Restoration work site

  Command: git stash apply / git stash apply stash @ {0} ( designated recovery site)
  Description: Restores stash contents
Note: stash the contents will not be deleted after restoration

Delete the job site

  Command: git stash drop
  Description: Delete stash content

Restore and delete the job site

  Command: git stash pop
  Description: Restore and delete stash contents
Note: After restoring stash will be deleted

Label Management

git View Tag List

  Command: git tag
  Description: View a list of labels

git tagging

  Command: git tag [name] / git tag -a [tagname] -m [ tab description] [commit_id]
  Description: git tagging

git to specify commit_id tagging

  Command: git tag [name] [commit_id ]
  Description: git tagging to specify commit_id

The local label git push to a remote repository

  Command: git push [remote repository] [tagname] / git push [remote library] --tags (all local tags pushed to the remote repository)
  Description: The name specified label specified pushed to the remote library

View git tag information

  Command: git show [tagname]
  Description: presenting information corresponding label

git remove tags

  Command: git tag -d [tagname]
  Description: Deletes the specified name tag

git to delete the label on a remote library

  Command: git push [remote library]: refs / tags / [tagname ]
  Description: Deletes the specified name tag on the remote repository

Guess you like

Origin blog.csdn.net/weixin_33795093/article/details/90934317