📅  最后修改于: 2023-12-03 15:00:55.237000             🧑  作者: Mango
As a programmer, you will likely use Git on a daily basis to manage your code projects. Git is a powerful version control system that tracks changes made to your code over time. In this cheat sheet, we will cover some of the most common Git commands that you will use in your day-to-day work.
The git init
command initializes an empty Git repository in your current working directory.
$ git init
The git clone
command creates a local copy of a remote Git repository.
$ git clone <repo URL>
The git add
command adds a file or folder to the staging area.
$ git add <file/folder>
The git commit
command saves your changes to the Git repository.
$ git commit -m "commit message"
The git push
command pushes your local changes to the remote Git repository.
$ git push origin <branch>
The git pull
command updates your local repository with changes from the remote repository.
$ git pull origin <branch>
The git status
command shows the current state of your Git repository.
$ git status
The git branch
command lists all of the branches in your local repository.
$ git branch
The git branch <branch name>
command creates a new branch in your local repository.
$ git branch <branch name>
The git switch <branch name>
command switches to an existing branch in your local repository.
$ git switch <branch name>
The git checkout <branch name>
command switches to an existing branch in your local repository.
$ git checkout <branch name>
The git merge <branch name>
command merges changes from a specified branch into your current branch.
$ git merge <branch name>
The git branch -d <branch name>
command deletes a specified branch in your local repository.
$ git branch -d <branch name>
This Git cheat sheet covers many of the most common commands that you will use when working with Git. With this knowledge, you should be able to use Git to effectively manage your code projects. Remember to always commit changes frequently and to create branches to isolate your work when necessary. Happy coding!