Marjer
Marjer

Reputation: 1403

non-fast-forward Error while pushing folder into github

I'm using Git bash to push my "newfolder" to github.

I tried the below steps,

cd git
git add newfolder
git commit -m 'first commit'
git remote add origin7 http://host.com/project.git

All went well upto this, but while pushing it into github it's failed with (non-fast-forward).
git push origin7 master

! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'http://host.com/project.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

please let me know how to resolve this. Thanks in advance.

Upvotes: 0

Views: 142

Answers (2)

Bojangles
Bojangles

Reputation: 101473

The command's error message tells you how to solve it right there. Why that message is shown is due to the fact your local repository doesn't have the latest changes, and is therefore refusing to (potentially) overwrite them.

You can solve this by updating your local copy with git pull, resolving any merge conflicts, then pushing up to Github using git push origin7 master as usual.

Upvotes: 1

rderoldan1
rderoldan1

Reputation: 4078

I looks like you have made changes in to GitHub, so your local version is behind, so you first have to pull those changes and after merge you can push to github

Upvotes: 1

Related Questions