GITHUB common commands

1 Common

Copy the code
Origin [email protected] the Add Remote git $: yeszao / dofiler.git          # configure remote git repository
Origin Master git pull $                                           # download the code and quickly merge Origin git master the Push $ # upload the code and quickly merge git FETCH Origin $ # to get the code from a remote repository $ git Branch # Display all Checkout master git branch $ # to switch to the master branch git Checkout -b dev $ # Create and switch to the dev branch "First Version" $ git the commit -m # submit $ git status # check the status of git $ log # View commit history $ git config - , Ltd. Free Join core.editor vim # set the default editor to vim (git default with nano) $ git config core.ignorecase false # set a case-sensitive $ git config - , Ltd. Free Join user.name "YOUR nAME" # set the user name $ git config -user.email, Ltd. Free Join "YOUR EMAIL ADDRESS" # Set Mailbox
Copy the code

Alias ​​Alias ​​2

Copy the code
Git config $ - , Ltd. Free Join alias.br = "Branch"                  # create / view local branch
Git config $ - , Ltd. Free Join alias.co = "Checkout" # handover branch git config $ - , Ltd. Free Join alias.cb = "Checkout -b" # Create and switch to a new git config branch $ - , Ltd. Free Join alias.cm = "the commit "-m # submit git config $ - , Ltd. Free Join alias.st =" status " # check the status of git config $ - , Ltd. Free Join alias.pullm =" pull Origin Master " # pull branch git config $ - , Ltd. Free Join alias.pushm = "Push Origin Master" # Submit branch $ git config - . Global Alias log = "log --oneline --graph --decorate --color Git = Always" # single line, different colors display record $ git config -global alias.logg="git log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative" # 复杂显示
Copy the code

3 Create Repository

Git $ clone <url>                  # clone a remote repository
The init git $                         # initialize the local repository

4 modify and submit

Copy the code
Status git $                       # View state
Git diff $                         # see what's changed Git the Add $. # Keep track of all changed files git the Add $ < File> # trace file specified git mv $ <Old> < new new> # file renamed git RM $ < File> # delete the file $ git rm --cached < file> # stop tracking files but does not remove the commit -m git $ "the commit the Message" # submit all updated files git the commit --amend $ # modify the last commit
Copy the code

5 View submission history

Git $ log                          # View submission history
Git $ log -p < File> # View the specified file submission history git blame says $ < File> # in a list view of the specified file submission history

6 Undo

Git $ the RESET --hard the HEAD            # undo any uncommitted modify the contents of the file in the working directory
Git $ the RESET --hard <Version> # revoked to a specific version of the HEAD $ git checkout < File> # undo changes $ git checkout content specified for submitting the documents - < File> # ditto command $ git revert <commit > # revoke the specified submission

7 branches and tags

Copy the code
Branch git $                       # display all local branches
Git Checkout $ <Branch / Tag>        # switch to the specified label or branch Branch git $ < new new-Branch> # Create a new Branch git branch -d $ <Branch> # Delete the local branch git Tag $ # List all local git Tag labels $ <Tagname> # based on the latest submission to create labels $ git tag -a "v1.0" -m "some indication" # -a label name is specified, -m specify the label instructions git tag -d $ <Tagname> # delete tag $ git Checkout dev # merge specific commit to dev branch $ git cherry -pick 62ecb3
Copy the code

8 combined with the rebase

Merge git $ <Branch>               # consolidates branch to the current branch
Merge git --abort $                # to cancel the current merger, reconstruction of pre-merger state Git Merge dev -Xtheirs $ # to incorporate dev branches to the current branch, branch dev places conflicting Git rebase the subject $ <Branch> # rebase branches to the specified current branch

9 Remote Operation

Copy the code
Git Remote -v $                    # View remote repository information
Remote Show git $ <Remote>         # View the specified remote repository information $ Git Remote the Add <Remote> <url> # add a remote repository $ git Remote the Remove <Remote> # delete the specified remote repository $ git FETCH <Remote> # Get the code $ git pull <remote> from a remote library <branch> # Download the code and quickly merge git the Push $ <remote> <branch> # Upload the code and quickly merge git the Push $ <remote>: <branch / tag-name> # delete remote branch or tag git the Push the --tags $ # upload all label
Copy the code

10 pack

Git = ZIP Archive --format $ --output ../ file.zip master     # the master branch packaged into file.zip files stored on a directory
Git = ZIP Archive --format $ --output ../v1.2.zip v1.2       # pack v1.2 tag files stored on a file directory v1.2.zip Git = ZIP Archive --format $ v1.2> ../v1.2.zip # effect above a command

git package command automatically ignore .gitignorespecified directories and files, and .gitdirectories.

Global and local configuration 11

  • Global configuration is saved in:$Home/.gitconfig
  • Local repository configuration is saved in:.git/config

12 remote and local merger

If you create code in a remote warehouse, and has been initialized, the local is the specific source code, then the workflow should be:

The init git $                               # initialization code for local warehouse
Git the Add $.                              # Add native code The commit -m git $ "local the Add Source" # submit native code git pull Origin master $ # Download Merge master git remote code $ # merge the Push -u git master branch Origin master $ # upload the code

You can focus on micro-channel public number: lovephp, together with the exchange of learning

Guess you like

Origin www.cnblogs.com/qiu18359243869/p/11141696.html