0

I'm trying to push to my GitHub repository, Link to my GitHub repo if needed

To https://github.com/laukomatic/RL-k_armed_bandit.git ! [rejected] main -> main (non-fast-forward) error: failed to push some refs to https://github.com/laukomatic/RL-k_armed_bandit.git hint: Updates were rejected because a pushed branch tip is behind its remote hint: See the Note about fast-forwards in git push --help for details. From https://github.com/laukomatic/RL-k_armed_bandit 

Than I tried pulling to update with: git pull origin main.
But it didn't work it said:

 * branch main -> FETCH_HEAD Already up to date. 

when I tried: git status, it gave:

On branch master nothing to commit, working tree clean 

But it is still not possible to push.

I have already did git add . and git commit -m "some message".

Also if it helps, I'm a complete beginner, I watched one tech with Tim tutorial. Also when I firstly pushed to the remote repository I pushed with Plotting_results. Which was created as a checkout. Than I updated it with master checkout.

0

2 Answers 2

3

There are two different issues here. One is that you created the README directly at GitHub after having already pushed four commits on main to GitHub. So now GitHub has that commit (7d1e6cb9f61b0fd7e2b86207577705b1d0c22cc7) and you don't. So you cannot push until you have pulled that commit into your local.

The other issue is that you're working on master in your local but there is no master on GitHub. You said git pull origin main, and that causes main to get merged into your master. This is a messy mismatch and is confusing the heck out of you. If you want to be able to push from your local to main, you need to be on main and pull main from GitHub and then push to main. You should get rid of master locally so you don't get all confused about where you are and what you're doing.

Sign up to request clarification or add additional context in comments.

1 Comment

Everything about your situation, almost, is discussed in my article biteinteractive.com/of-git-and-github-master-and-main
0

I tried git push -u origin main, but was getting this error, enter image description here

then I did fetch the origin main and did the following things, look at the second image after the error.

enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.