Git Error | GitHub Error: failed to push some refs to '[REPO URL]'

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you just getting started with git and github and you are getting this error message failed to push some refs too and then your repository url are you getting that here is how your repository might be looking like on github you may have chosen to add a readme file automatically to your new repo this file triggers a new commit here's where all starts then your local environment you have already the folder that you are working on and you may even have some files that you want to check into this repo i'm going to run the get commands from within vs code so i'm just going to run the terminal i'm going to change the folder should be this one change directory right there and then i'm going to run get init to initialize the local repo after doing that i'm going to go and type in get ads add new files all new files dots we have moved from working environment to the staging area now i'm going to run the get commit dash m i'm going to put the message here first commit which to be honest is not really the first one but let's put it that for now as we think that this is the first commit now we're gonna connect the local get to the remote one and for that we're gonna run get remote ads orange that's the name that we're gonna be using to reference the remote one and then we're gonna put the url here is the get url i'm gonna copy that i'm gonna paste it here and the connection is made natural next step we're gonna try to push those changes to the remote one and you're gonna run get push the shoe origin master we have a problem that's the euro failed to push some refs to the get url how do we solve that well first of all what is the problem the problem is that you have a commit already performed on the remote github repo and also on your local one but they are not aware of each other so one commit happens after the other one after the other one you have two parallel commits that neither of them are aware of each other so we have to combine them together that's called rebasing we're gonna have to rebase our repository to do that we're gonna run git pull dash dash ring base this is what we'll do the read basing we're gonna get the files in the remote repository we're going to bring them locally and then we're going to force one commit to be placed after the other one then oranging and the name of the branch we are working with the master so the branches have been sequenced properly and we are ready to push this new setup back to the remote repository before we do that if we try get log we're gonna see that we have the first commit and then the initial one the initial one is the one that was on github the first commit is the one that we did locally so now you can see that it's one after the other we have been able to sequence them and we solved the conflict now we are ready to push the changes to github so get push dash u orange master let's try that this time around we had no problems if we check on github you're gonna see that we have our initial commit and then we have our what i called first commit which is the second actually the second one that's it that's how you can solve the error fail to push some refs to repo one note of warning is that only use this strategy if you are just creating your repo right now and you don't have a more complex situation in your hands with a larger project that's it thanks bye
Info
Channel: The Solo Coder
Views: 226,690
Rating: undefined out of 5
Keywords: git, github, error, errors
Id: IeL7iq7Lb90
Channel Id: undefined
Length: 3min 58sec (238 seconds)
Published: Wed Sep 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.