Submit the local project to the remote warehouse with git

The folder project created locally can be submitted to the remote Git repository through the following steps:

Create a new empty repository in the remote Git repository. For example, a new repository can be created on GitHub.

Initialize the Git repository with the following command in the local project root directory:

   git init

Associate a local project with a remote Git repository using the following command, where remote-url is the address of the remote Git repository:

   git remote add origin remote-url

Add the local project's code to the Git repository with the following command:

   git add .

This will add all changed files to the Git repository, you can also use the git add file-name command to add specified files.

Use the following command to submit the code to the local Git warehouse, where commit-message is the message of this submission:

   git commit -m "commit-message"

Use the following command to push the code in the local Git repository to the remote Git repository:

   git push -u origin master

This will push the master branch code from the local Git repository to the remote Git repository.

It should be noted that when executing the above commands, it is necessary to ensure that the code branches and submission records in the local and remote Git warehouses are consistent to avoid problems such as code conflicts. At the same time, it is recommended to back up important code files before submitting the code to prevent unnecessary code loss

Guess you like

Origin blog.csdn.net/weixin_43031220/article/details/130540444