Uploading local files to a remote git server

Source: Internet
Author: User

1, (first into the project folder) through the command gitinit this directory into git can manage the warehouse

Git init

2, add the file to the local repository, use the command git add file, add to staging area inside, if the next decimal point ".", meaning to add all the files under the folder

git Add.

3. Use the command git commit to tell git to submit the file to the repository. In quotation marks for submission instructions

Git commit-m ' first commit '

4. Associating to remote libraries

Git remote add origin your repository address

Such as:

git remote add origin [email protected]:/srv/sample.git

If the above steps are incorrectly written:

GIT remote RM origin//Delete origin

git remote add origin [email protected]:yourname/demo.git//re-add Origin

5, get remote library and local synchronization merge (if the remote library is not empty must do this step, or the subsequent commit will fail)

Git pull--rebase Origin master

6. Push the latest changes to the remote repository: Gitpush-u Origin Master

Note: Origin: Remote repository name; Master: Branch

Note: When we first push, with the-u parameter, git associates the local master branch with the remote Master Branch, and we no longer need to add the-u parameter to the push operation.

If something like the following appears:

Username for ' https://github.com ': shiren1118

Password for ' https://[email protected] ':

To Https://github.com/shiren1118/iOS_code_agile.git

! [Rejected] master, master (Non-fast-forward)

Error:failed to push some refs to ' https://github.com/shiren1118/iOS_code_agile.git '

Hint:updates were rejected because the tip of Yourcurrent branch is behind

Hint:its remote counterpart. Merge the remote changes (e.g. ' git pull ')

Hint:before pushing again.

Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.

Then enter the command: Git push-u origin master–f can fix the problem

If you get the files on a git server from another account on the same host as the GIT server, use the

Gitclone + git repository path, i.e.: gitclone/srv/sample.git/

Source:

73732769

Uploading local files to a remote git server

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.