tencent cloud

All product documents
Common Commands
Last updated: 2023-12-25 17:08:18
Common Commands
Last updated: 2023-12-25 17:08:18
This document describes the common Git commands.

Create Repository

$ git clone <url> # Clone a remote repository
$ git init # Initialize a local repository

Modify and Commit

$ git status # View status
$ git diff # View changes
$ git add . # Track all files with changes
$ git add <file> # Track a specific file
$ git mv <old><new> # Rename a file
$ git rm <file> # Delete a file
$ git rm --cached <file> # Stop tracking a file without deleting it
$ git commit -m "commit messages" # Commit all updated files
$ git commit --amend # Modify the last change

View Commit History

$ git log # View commit history
$ git log -p <file> # View the commit history of a specific file
$ git blame <file> # View the commit history of a specific file as a list

Revert

$ git reset --hard HEAD # Discard all uncommitted modifications in the working directory
$ git checkout HEAD <file> # Discard uncommitted modifications in a specific file
$ git revert <commit> # Revert to a specific commit
$ git log --before="1 days" # Show commits created 1 day ago

Branch and Tag

$ git branch # Show all local branches
$ git checkout <branch/tag> # Switch to a specific branch and tag
$ git branch <new-branch> # Create a new branch
$ git branch -d <branch> # Delete a local branch
$ git tag # List all local tags
$ git tag <tagname> # Create a tag based on the latest commit
$ git tag -d <tagname> # Delete a tag

Merge and Rebase

$ git merge <branch> # Merge a specific branch to the current branch
$ git rebase <branch> # Rebase a specific branch to the current branch

Remote Operations

$ git remote -v # View remote repository information
$ git remote show <remote> # View the information of a specific remote repository
$ git remote add <remote> <url> # Add a remote repository
$ git fetch <remote> # Fetch code from a remote repository
$ git pull <remote> <branch> # Download code and merge
$ git push <remote> <branch> # Upload code and merge
$ git push <remote\\> :<branch/tag-name\\> # Delete a remote branch or tag
$ git push --tags # Upload all tags
For more information, see the Git Documentation.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon