While deploying the blog recently, I reviewed the Git commands I use. Here are my notes.

Git branches

1. Clone a repository

git clone git@github.com:userName/CategoryName.git

2. Manage branches

List branches

Local branches

Use git branch:

$ git branch
* master

The asterisk marks the branch you are currently on.

Remote branches

git branch -r

All branches

git branch -a

Create a local branch

git branch [branch name]

Switch to a branch

git checkout [branch name]

Create and switch to a branch

git checkout -b [branch name]

Push a new branch to GitHub

git push -u origin [branch name]

Delete a local branch

git branch -d [branch name]

Delete a remote branch

git push origin :[branch name]  # The colon requests deletion

3. Commit local changes to a new branch

Switch to the branch

git checkout [branch name]

Stage the local changes

git add .

Commit the changes

git commit -m "Site Updated By Team RubyCore."

Push to the Git repository

git push -u origin [branch name]

Reference:

  1. https://blog.csdn.net/chen134225/article/details/95475960