Premise: Creating a new project or go on gitlab github website, remember to add the complete .ignoe;
1. Open a terminal, cd to the directory of the project already exists
2, enter the following command line to initialize a local repository:
git init
3, enter the following command, all the project files are added to the repository (Do not forget the back of the number !!!.):
git add .
4, enter the following command to submit the file to the local repository:
git commit -m "Initial commit"
If nothing appears to commit, working directory clean that you have submitted good.
5, enter the following command to add a remote warehouse address:
Input: git remote add origin + your warehouse address
For example: git remote add origin https://git.oschina.net/hhh/GitDemo .git
If the fatal appear: remote origin already exists to show that you've added through a remote repository, enter the following command to delete the remote repository:. Git remote rm origin, and then perform Step 5 again.
6, enter the following command to submit the files to a remote repository:
git push -u origin master
Then you wait for it to submit complete get away.
7, Part 6 if it fails then execute git pull -rebase origin master command, and then execute git push -u origin master can be uploaded successfully.
8, if the first portion 7 performs git pull -rebase origin master command fails and a new remote project is empty item, the git push -u origin master -f command forcibly pushed to the remote.
9, after it's happened, then if you still can not pull the code and then restart the project implementation git branch -set-upstream master origin / master can be.
Reproduced in: https: //www.jianshu.com/p/ba96f53d6246