On the first day of work, you must know the routine git operations

Initialize a new repository:
Command: git init
Analysis: Create a new Git repository in the current directory for version control project code.

Clone a remote repository to the local one:
Command: git clone <repository_url>
Analysis: Clone the code from the remote repository to the local one and create a local copy for you to modify and submit.

Check the status of the warehouse:
Command: git status
Analysis: Check the status of the current working directory and staging area, including files that have been modified but not yet submitted and files that have been staged.

Add files to the staging area:
Command: git add
Analysis: Add the specified file to the staging area and prepare to submit it to the version history.

Submit the files in the staging area to the version history:
Command: git commit -m "commit_message"
analysis: Submit the files in the staging area to the version history, and attach a brief submission message.

View submission history:
Command: git log
parsing: Display the submission history of the project, including the submitted author, date, submission information, etc.

Create a new branch:
Command: git branch <branch_name>
Analysis: Create a new branch for developing new features or solving problems without affecting the main branch.

Switch to the specified branch:
Command: git checkout <branch_name>
Analysis: Switch to the specified branch and start working on the branch.

Pull the remote branch to the local one:
Command: git pull origin <branch_name>
Analysis: Pull the latest code from the remote warehouse and submit it to the specified branch.

Push the local branch to the remote warehouse:
Command: git push origin <branch_name>
Analysis: Push the submission of the local branch to the specified branch of the remote warehouse.

Merge branches:
Command: git merge <branch_name>
Analysis: Merge the modifications of the specified branch into the current branch.

The above are some commonly used Git operations and command analysis, which can help you track, submit and manage code in the version control system. Please note that in actual use, more Git operations and commands may be involved, and you can further learn and master them as needed.

Guess you like

Origin blog.csdn.net/weixin_41902931/article/details/130742986