git common command to turn

Reprint address

1) Remote warehouse related commands

Checkout the repository: $ git clone git://github.com/jquery/jquery.git

View the remote repository: $ git remote -v

Add a remote repository: $ git remote add [name] [url]

Delete remote repository: $ git remote rm [name]

Modify the remote repository: $ git remote set-url –push [name] [newUrl]

Pull remote repository: $ git pull [remoteName] [localBranchName]

Push remote repository: $ git push [remoteName] [localBranchName]

*If you want to submit a local branch test to the remote warehouse and use it as the master branch of the remote warehouse, or as another branch named test, as follows:

$git push origin test:master // Submit the local test branch as the remote master branch

$git push origin test:test // Submit the local test branch as the remote test branch

2) Branch operation related commands

View local branches: $ git branch

View remote branches: $ git branch -r

Create a local branch: $ git branch [name] --- Note that the new branch will not automatically switch to the current branch after it is created

Switch branches: $ git checkout [name]

Create a new branch and switch to the new branch immediately: $ git checkout -b [name]

Delete branch: $ git branch -d [name] --- The -d option can only delete the branch that has participated in the merge, and cannot be deleted for the branch that has not been merged. If you want to force delete a branch, you can use the -D option

Merge branches: $ git merge [name] --- Merge the branch named [name] with the current branch

Create remote branch (local branch push to remote): $ git push origin [name]

Delete remote branch: g i t p u s h O r i g i n : h e a d s / [ n a m e ] or gitpush origin :[name]

*Create an empty branch: (Remember to submit the changes to your current branch before executing the command, otherwise you will be forced to delete it without regret)

$git symbolic-ref HEAD refs/heads/[name]

$rm .git/index

$git clean -fdx

3) Version (tag) operation related commands

View version: $ git tag

Create version: $ git tag [name]

Delete version: $ git tag -d [name]

View remote version: $ git tag -r

Create remote version (local version push to remote): $ git push origin [name]

Remove remote version: $ git push origin :refs/tags/[name]

Merge the tags of the remote repository to the local: $ git pull origin --tags

Upload local tags to remote warehouses: $ git push origin --tags

Create annotated tags: $ git tag -a [name] -m 'yourMessage'

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324417532&siteId=291194637
Recommended