Create a remote git repository within the LAN and push the local warehouse push to the remote repository

Source: Internet
Author: User
Tags ssh
Create a remote git repository within the LAN and push the local warehouse push to the remote repository

1. telnet to the server in the LAN first

2. switch to a folder in the server,

Then create a new folder to use as a git repository (the folder name is best with the same name as the warehouse folder that is being pushed to the server).

and switch to this folder,

The GIT init command will then be used to build a git repository under this folder (the-bare parameter in the figure is to create a bare repository),

Then quit the server.

3. After exiting the server, switch the local path to the root directory of the local repository,

If you do not have a repository locally, use the GIT init command to create a local repository, as shown in

Then use the "Git Remote Add origin ssh://server SSH user name @ server IP Address Server +git warehouse path" command to the remote repository, the server git repository path is the path outlined in the 2nd Green Line,

(The plus sign is removed from the "Server IP Address Server +git warehouse path" above.) If the server repository is a folder in Windows, such as d:/code/, the server SSH user is Admin,ip 192.168.1.100, then the command is git remote add Origin ssh://admin@192.168.1.100d :/code/)

If you are prompted to indicate that Origin already exists, that is, "fatal:remote origin already exists", use the GIT Remote RM Origin command to delete origin, delete and re-execute git remote add Origin to associate the remote repository.

4. Add the project file to the local index library with the git add–a command

Then submit the file with git commit–m "xxx" Command Index library

5. Next, use the command GIT push origin master to push to the master branch of the remote repository, as shown in the figure for Operation success

Here the direct push push on the server warehouse, do not use pull pulls, or will error, the report can not find the master branch, because the server warehouse is empty, so there will be no branch

6. You can test whether the success

git remote show origin

Delete local repository and clone once to local

OK, Finish ~

The END

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.