Git commands to use finishing

A, git branch switching

1, there is no corresponding local remote branch

git fetch origin

git checkout -t origin / remote branch name

# Switch branch

git checkout branch name

2, a corresponding local remote branch

git checkout branch name

Two, git delete local branch and a remote branch

1, delete the local branch

Check local branch #

git branch

# Delete the local branch

git branch -d branch name

2, delete remote branch

View a list of remote branch #

git branch -a

# Delete remote branch

git push origin -delete remote branch name

Three, git revision and revocation of a local version rollback

  1. Use git checkout undo local edits; that is, give up the modified file to the local modified but not yet committed, restore its state before the unmodified

ATTENTION: add / commit files do not apply a method, you should use the second method mentioned herein.

Command is as follows:

git checkout. # undo changes to all modified but not submitted documents, but does not include the new file

git checkout [filename] # undo changes to the specified file, [filename] is the file name

  1. Use git reset fallback version of the project; can roll back to any version had been submitted. Has add / commit but did not push documents also apply

Command is as follows:

git log # commit View the hash value of

git reset –hard [commit-hashcode]

# [commit-hashcode] is a hash value of a commit, you can check with git log; therefore common usage
is to view the hash value of the specific commit with git log, and then reset to the version

Fourth, create a branch

git checkout -b branch name

git branch branch name

Computer rental hang idle resources to earn money electricity
use of idle computer resources to earn pocket money (for students, housewives)
Online generated outside the chain tool (International Edition)
generated on-line outside the chain tool (Chinese version)

Published 16 original articles · won praise 2 · Views 405

Guess you like

Origin blog.csdn.net/momoringmok/article/details/104934270
Recommended