-1

I already had this same project implementing a payment template in Angular, however I decided to start from the beginning but without a template, and I made a version of the previous project on GitHub, but now I want to upload the new project to the same repository, but it won't let me, How can I do it?

I just tried to push it to the repository and it shows me this

 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/................'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+remote+contains+work+that+you+do – phd Dec 01 '22 at 12:30

1 Answers1

0

That error is telling you that there are updates on the remote branch that you don't have locally. If you don't have any conflicting changes locally, you should be able to do

git pull

to pull the updates from remote to your local files. Assuming there are no conflicts, you should then be able to push your changes without issue. If there are conflicts, you need to resolve those.

However, if you are truly "starting from the beginning", it might be wise to use a new repository. If you are just adding a feature, refactoring, or otherwise redesigning the code, this is exactly what a branch is for. In which case you can do

git branch [branch_name]
git checkout [branch_name]

and then all of your new changes will only apply to that branch. You can later merge the two with a pull request.

lcleary
  • 65
  • 6
  • The OP wants to overwrite the content of the remote repo with a new project. `git pull` is an evil command here because it brings the content of the old project into the new. – phd Dec 01 '22 at 12:32
  • My advice is to remove the 1st part at all. – phd Dec 01 '22 at 12:38