0

I write my notes in Joplin. I export them as .md (markdown). It turns them into two folders: Resources consists of images. NGINX@HOME consists of markdown file.

Resources
NGINX@HOME (The name of my note book)

Now, I push them into github using this post. Next, I write 2nd note on NGINX. I write it in the same notebook as earlier. I export it as .md. Again it makes the two folders with same name as above because the notebook is same.

Now, I want to to push that code to github to the same repository. But when I try it I get various errors.

error: failed to push some refs to 'https://github.com/<my_github_id>/my_notes.git'
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.

I do git pull origin main but it still fails to upload.

fatal: refusing to merge unrelated histories

How do I resolve this issue?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
zeeshanseikh
  • 117
  • 7
  • 2
    Apparently, you have two unrelated git histories. For your "2nd note", did you create a _new_ local git repo, or you continue using (or make a clone of) the original repo? – Brian61354270 Aug 19 '23 at 13:10
  • I created a new local git repo. – zeeshanseikh Aug 19 '23 at 13:15
  • 1
    I see. Do you care about preserving commit history in the second repo? Or do you just want to add the new files to the original repo? – Brian61354270 Aug 19 '23 at 13:22
  • 1
    As a side note, why this is happening and what you should do going forward may make a lot more sense if you [read up on git itself](https://git-scm.com/book/en/v2). – Brian61354270 Aug 19 '23 at 13:24
  • I just want to add the new files to the original repo. @Brian61354270 I'll immediately start learning from that book. Thank you for recommending it. – zeeshanseikh Aug 19 '23 at 13:29

1 Answers1

-4

You should first resolve your merges and Then again use

git add .
git commit -m ""
git push origin main