git error failed to push some refs to remote

0 votes

When I use the git push origin master this happens.

gitbashscr

This is what my working directory and remote repository look like:

Screenshot of Windows file folder with these directories: .git, css, js. And these files: index.php, readme, setsu.php. The word "local" with an arrow points to the css-folder. Below, screenshot with heading "github", and a css-folder and index.php-file

Can someone explain to me why I can't push? and why is this happening?

Apr 30 in Git & GitHub by Kichu
• 19,040 points
3,795 views

1 answer to this question.

0 votes

I would advise using:

git pull --rebase

git push

The GitHub repo has seen new commits pushed to it while you were working locally.

Here is the full syntax:

git pull --rebase origin main

git push origin main

After that use, a simple git pull would do the job. In this way, you can replay (the --rebase part) your local commits on top of the newly updated origin/main (or origin/yourbranch: git pull origin yourBranch).

Note: git reset --mixed origin/main can also be written git reset origin/main, since the --mixed option is the default one when using git reset.

I hope this helps.

answered May 2 by narikkadan
• 37,660 points

Related Questions In Git & GitHub

+2 votes
3 answers
+1 vote
1 answer

master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:abc70/new.git'

Hi@akhtar, To update your local repo to GitHub ...READ MORE

answered Feb 14, 2020 in Git & GitHub by MD
• 95,380 points
16,138 views
+1 vote
1 answer
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
2,084 views
+2 votes
1 answer
0 votes
1 answer

GitHub "fatal: remote origin already exists"

Update the existing remote: $ git remote set-url ...READ MORE

answered May 1 in Git & GitHub by narikkadan
• 37,660 points
497 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP