0

I am trying to sync a local repository with the master repository on the git hub website. I am not sure what the issue is. I will include the commands and errors I am getting in the local shell.

git push

fatal: No configured push destination. Either specify the URL from the command-line or configure a remote repository using

git remote add <name> <url>

and then push using the remote name

git push <name>

git push -u https://github.com/winteralfs/thr3d_scripts.git master

! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/winteralfs/thr3d_scripts.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

git pull

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=<remote>/<branch> master

--

How can I resolve this? Thank you.

winteralfs
  • 459
  • 6
  • 25

1 Answers1

1
  1. git push => fatal: No configured push destination.

    Then very simply, just add a "remote" to your local repo.

    EXAMPLE: git remote add origin https://github.com/winteralfs/thr3d_scripts.git

  2. Make sure you've correctly added it:

    EXAMPLE git remote -v

  3. Make sure you're on the "master" branch (or at least you're on whatever branch you intend):

    EXAMPLE: git branch -a

  4. Finally, assuming you're ready to push to remote:

    EXAMPLE: git push origin master

Now, if you still get "Updates were rejected because the remote contains work that you do not have locally...", then:

5a. FIRST, take a backup of your local repo ("just in case...")

5b. THEN:

  • try git pull origin master
  • make sure everything is OK on your local PC,
  • then try git push... again.

Useful links:


New error:

git pull origin master From github.com/winteralfs/thr3d_scripts * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories

Related link: Git refusing to merge unrelated histories on rebase

Suggestions:

  1. If you're absolutely totally 100% sure the remote has what you want, and you've got the right branch (for example, if you don't have any branches besides "master"), then you can use this syntax:

    • git pull origin master --allow-unrelated-histories

    I would not advise this. Instead, I suggest:

  2. Clone your remote into a new directory, and reconcile manually:

    1. mkdir some-new-folder

    2. cd some-new-folder

    3. git clone https://github.com/winteralfs/thr3d_scripts.git

    4. Manually "diff" the files between your local repo and the clone ...

    5. ... or simply copy everything EXCEPT ".git" from your local repo over the clone

    6. When you're satisfied, "git push" back to GitHub

That's probably the safest, surest and easiest way to bring everything back in sync.

'Hope that helps...

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • git pull origin master From https://github.com/winteralfs/thr3d_scripts * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories – winteralfs Feb 25 '19 at 00:29