C
C
CoyoteSS2019-07-05 10:59:58
git
CoyoteSS, 2019-07-05 10:59:58

Why does Git say I have an error on git push when I shouldn't have one at all?

1) Did a "git init" in the local folder
2) Created a remote repository on GitHub
3) Created a .gitignore file in the local folder (node_modules, src)
4) Added a .gitignore file to the local repository
5) Made a commit to the local repository
6) Linked remote repository with local "git remote add origin { link }"
7) Pushed changes from local repository to remote "git push origin master"
Got the following picture:
5d1f037a2c5bd297148515.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0x1b6e6, 2019-07-06
@CoyoteSS

were there any commits on the remote repository before git push?
if yes, then before the first local commit, you need to do git pull origin master.
you can do this (but .gitignore will be deleted, and I'm not responsible for other files)

git pull --force origin master
git push -u origin master

well git push --force -u origin master, or like this: but all changes will be erased remotely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question