Tag Archives: Updates were rejected because the remote contains work that you do

Updates were rejected because the remote contains work that you do

Every time you build a new warehouse, there will always be such an error when you submit it. It’s really a headache

The steps of GIT submission are as follows:

1. Git init// initialize the warehouse

2. Git add. (file name)// add file to local warehouse

3. Git commit – M “first commit”// add file description information

4. Git remote add origin + Remote warehouse address// link the remote warehouse and create the main branch

5. Git push – U origin master// push the files of the local warehouse to the remote warehouse

The following error occurs after submission

to solve the above errors, you only need to use git pull origin master between 4 and 5

Correct procedure:

1. Git init// initialize the warehouse

2. Git add. (file name)// add file to local warehouse

3. Git commit – M “first commit”// add file description information

4. Git remote add origin + Remote warehouse address// link the remote warehouse and create the main branch

5. Git pull origin master// connect the changes of the local warehouse to the main branch of the remote warehouse

6. Git push – U origin master// push the files of the local warehouse to the remote warehouse

Reprint address: https://www.cnblogs.com/alex-415/p/6912294.html