Contributing to Codecademy Docs repository issue

Hola,

although I have found the same topic opened years ago towards the “Contributing to Codecademy Docs repository” exercise, unresolved (and closed), I have the very same problem I have no idea how to resolve:


! [rejected] topic-content-term → topic-content-term (fetch first)
error: failed to push some refs to ‘GitHub - Iampetrus/docs: Codecademy Docs is a collection of information for all things code. 📕
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 get the above once I (try to) push after corrections were made to my first attempt.
Any idea how can I just make it work?
I have tried quite a few things but they all fail.

Thank you

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!
1 Like

Have you tried, as suggested in the hint, running git pull before reattempting to push your changes?

3 Likes

Can you attach a screenshot of this error? I think I once faced what you are facing right now. I think I fixed it by branch rebasing. Though I can further clear it by look at the error screenshot @thepitycoder.

1 Like

I did without success

screenshot pasted as shown in the post above

ok.

In the following link you can have a look at all steps taken to complete the exercise once assigned to me by Codecademy:

Once I added my version I was invited to
@Iampetrus Please update the entry, and tag me when you’ve finished making changes. Thanks”
which I did as you can see in the link.
When I was trying to push my update from VS terminal, the error message was shown.

Now, the second chapter of this post comes when other collaborators completed the process for me on github, finishing the exercise (also in the link). This put me in a new situation in VS Code that you can see in the following capture:

So:
Question 1:
Can you tell me what took me to the very first error message?
Question 2:
How can I resolve the status of my VSC you can see in the capture?

I think I need to (let’s say) start with basic steps to follow in order to understand the process to add, pull, merge, push etc. I am sure I am missing some taking me to the roadblock Im at.
Any suggestions?

Hey @thisispetrus Sorry for the delayed reply I will look into your issue now. I’m not at home right now so I’m having a big issue getting online.

1 Like

This error message typically occurs when you try to push changes to a branch on GitHub that has been updated by someone else since your last pull or clone operation. The error is essentially telling you that there are conflicting changes between your local repository and the remote repository. The easy fix for this is:

  • Go on your forked repo.
  • Once you are in main branch click on sync fork and sync it with the main branch from original Codecademy branch.
  • In your case your main branch is behind the original branch
  • Once your main is synced it should look like this
  • Now go to your local system and where repo exist type: git pull origin main
  • This will sync your local repo with your remote repo.
  • Once you have done the above steps try to commit now and push the changes.

Let me know if this fixes the issue. If not we will find other ways which I know but first try the above steps.

1 Like

This is what was said above:

“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.”

2 Likes

Yes, I know and I saw the comment. Well I went to their repo and noticed that the author’s forked repo was not synced with the main repo. So if you run this command git pull command without specifying a remote or branch or even if you specify the branch name, it will pull changes from the remote repository and merge them into the current branch you’re working on. However, it will not automatically sync your forked repository’s main branch with the main branch of the original repository. So I mentioned the easy way above to sync the repo but there’s another way to add the upstream then fetching the main branch. I just elaborated the steps to follow. The other way is :

  • git remote add upstream original-repo-url
  • git fetch upstream main
  • git checkout main
  • git merge upstream/main
  • git push origin main
1 Like

Hey,
I think Im not used at all to this courtesy here in Codecademy.
Thank you for your answers @dakshdeephere !!!

I’m getting my notes together and coming back here once I organize them.
Enjoy the weekend!

1 Like

Hey, don’t worry your problem will be fixed if not please keep us updated. I also learn new things about git everyday, you can’t just complete git like a syllabus but it’s something you’ll learn more by gradually using it. Get use to basic commands in Git and slowly you’ll learn more fixes.

2 Likes

Yes, things were as you suggested.
From my understanding, matching content between local - github is the very basics to start from.

There’s just one last thing I would like to understand about VC.
If you see the following capture:


There are still 2 things to address as the small number 2 indicates in the primary sidebar.
If branches were synced earlier and updated, why is it still throwing that number? I understand something is left to be updated, although the terminal states “Everything up-to-date”

What’s left then?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.