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