Problems with adding items from local to remote repository under Git

Source: Internet
Author: User

Create a new bookstore repository on GitHub, and then initialize, only the readme.md file exists in the repository.

To create a new git repository locally:

1, mkdir Bookstore

2. CD Bookstore

3. Git init

4. Add files (file)

5, git add file1 file2 file ...

6. Git commit-m "Add Files"

7. Git remote add origin [email protected]:hahaha/project.git

8. Git push-u Origin Master

Here, an error message appears:

Error:failed to push some refs to ' [email protected]:michaelliao/learngit.git '

Hint:updates were rejected because the tip of your current 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.

This prompts the push to fail because a readme.md file is initialized on GitHub, and the files in the remote repository are newer than the local one, so use git pull to capture the latest files and then submit them after merging with the local files.

9. Git pull

Prompt error:

Remote:counting Objects:5, done.

Remote:compressing objects:100% (2/2), done.

Remote:total 3 (Delta 0), reused 3 (Delta 0)

Unpacking objects:100% (3/3), done.

From Github.com:michaelliao/learngit

fc38031. 291bea8 Dev-and Origin/master

There is no tracking information for the current branch.

Please specify which branch your want to the merge with.

See Git-pull (1) for details

Git pull <remote> <branch>

The reason is that the local master and remote Origin/master connections are not specified.

10. Setting up the connection

$ git Branch--set-upstream Master origin/master

11. Git Pull

12. Then submit

git commit-m "merge README. MD "

13. Git push-u Origin Master

Complete the local upload remote repository.

Problems with adding items from local to remote repository under Git

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.