0

so I'm supposed to be forking from the main repository and then pushing/pulling everything from my fork. However, I screwed up and cloned, and created a branch locally from the main repository instead.

Is it possible for me to push the code that I have been working on to the forked repository?

I tried adding a remote to the forked repository to push, but I keep getting this error:

Updates were rejected because a pushed branch tip is behind its remote counterpart. 
Check out this branch and merge the remote changes (e.g. 'git pull') before pushing 
again.

How should I solve this issue? PS, im pretty new to Git. I have git pull from the main repository and tried to git pull from the forked repository (this is weird to me since my branch is from the main repository...) , so everything is up to date but I still get the above error.

EDIT: Okay, so I was being a moron the whole time. So how I solved this is that I was basically created a branch on my forked repository, and then pushed to that branch. I was being a moron the whole time because what I did was git push forked_repo and I did not specify a branch, and being the dumbass that I am, I tried to do a git push forked_repo mylocalbranchname, thinking it would automatically create a branch for me. So once, I created the branch in my forked repo properly, I was able to push it into the newly created branch with no issues.

Mad apologies to such a dumb question LOL.

Also since I cloned the main repo onto my local computer, should I just delete the entire repo, and re-clone the forked one? What is the best practice for this?

kohrhea
  • 159
  • 7
  • 1
    `but I keep getting this error:` have you read the error message :)? It says how to solve. If you’ve tried what it says to do please edit the question to demonstrate that (please always include the commands issued and their full response in questions) – AD7six Jan 27 '22 at 06:47
  • Hey, thanks for the help, but I managed to solve it on my own, I was being dumb the whole time HAHA – kohrhea Jan 27 '22 at 08:00

0 Answers0