Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add a local project to a remote git repository

Shulou Source: shulou.com Published: 2022-06-03 17:54:28 09月30日 Update

This article mainly introduces "how to add the local project to the remote git warehouse". In the daily operation, I believe that many people have doubts about how to add the local project to the remote git warehouse. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to add the local project to the remote git warehouse". Next, please follow the editor to study!

There are two methods: this article focuses on the second.

Method 1:

Create an empty remote git repository; pull to an empty local directory, and the local empty directory automatically becomes a local repository associated with the remote git repository; copy your project files to the empty directory created in the previous step; add the files to git and submit. Got it.

Method 2:

Step 1: create a remote git repository.

Now there are a variety of git repositories available on the network, and everyone is free to choose; if you have conditions, you can also build a git server on your own server. I will not repeat it here.

Step 2: create a local project

Create your own project, and the tool's own work type is created at will.

Step 3: step 3, set up a cost warehouse for the directory where the local project is located.

Go to the directory where the project is located, and right-click git bash

Open the console of git and enter the command git init

At this point, the local project directory has become a local warehouse

Step 4: add the project files to the local warehouse

Git add. Please note that there is a dot behind the add

Step 5, submit the added files to the local warehouse

Git commit-m 'first add code'-m is followed by the log of this submission

Step 6, add a remote warehouse address

Git remote add origin http://xxxxxxxxx.git associates the address of the remote warehouse with the local warehouse

Git remote-v can view the addresses that have been added

Step 7, merge the remote library with the local library

Git pull-- rebase origin master Note: there are two minus signs, and many people fail to submit because of the lack of this step.

Step 8, push the files from the local warehouse to the remote warehouse

Git push origin master

So your local code has been uploaded to the remote warehouse.

At this point, the study on "how to add a local project to a remote git repository" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Warehouse project file method directory learning address selection location more server empty directory association help service utility freedom and then two introduce Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei NVidia Shulou Information Apple Shulou Tech Info