Git require me to pull before I push


#1

Hi, I’m having a problem overwriting the file currently in the repository with the new uploads so I’ve been trying to use git push -u origin master, but this error keeps popping up saying [rejected] master -> master (non-fast-forward) error: failed to push some refs ….Below are the command I’ve used. I’m new to this git/github and I am not yet familiar with the correct way of doing it. Hope you could help me thank you.

C:\Users\christine\Documents\google-homepage>git fetch C:\Users\christine\Documents\google-homepage>git add . C:\Users\christine\Documents\google-homepage>git commit -m "Second commit" On branch master nothing to commit, working tree clean C:\Users\christine\Documents\google-homepage>git push -u origin master To https://github.com/christine-27/google-homepage ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/christine-27/google-homepage' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.


#2

Hi Christine,

As the error states your local branch is behind the remote counterpart.

You used git fetch which only fetches a repo’s contents but doesn’t merge it. You should try git pull origin master to see if your local branch can be easily merged with the remote one.

You may have some merge conflicts which will need to be addressed if you’ve made changes to your local repo.

Give the above a try and let us know if you have any issues.


#3

Hi, Thank you for your clear and helpful explanation. It is okay now. :slight_smile: