Splendid !

Magnificent ! After a few days or development I decided to create a repository to be very sure not to lose anything. As soon as I clicked on Push, everything has instantly disappeared. I presume this is not the aim of Git. Is there an operational mode somewhere, other than the one that led me there ?

I think I should reformulate my question (I did not see any “Edit” button, is there ?) Did anyone already succeed in pushing an existing project into a Git repository, that was created afterwards ?

So I realized I had to create a new project, and link it to my repository before doing any modification in it. Maybe I shall do the development in another project, and transfer it from time to time to the linked project, to avoid side effects.

Well but when linking the project to the repository just after creating the project, I get an error :

“rejected Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes before pushing again.”

Well, my repository contains .gitattributes, and .gitignore, and that is all. And they are empty.

Is the solution to suppress the repository and create a new one ?

If there are incoming changes, why not propose me to pull them ?

This latest error is basically saying that you:

  1. Created a Git repository with a history A-B-C (on GitHub)
  2. Created a Git repository with a history X-Y-Z (locally)
  3. Then told Git to push history X-Y-Z onto A-B-C

Because there’s no common point of reference, Git can’t figure out in an automated fashion what it is likely you want. So the error is suggesting that you pull the A-B-C history down, manually sort out what you want, and then push the result back up.

Or the faster way would possibly be to delete the repository on GitHub, create a new one with no contents, then push your local contents up to the new repository.

I hope that helps!

1 Like