Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

bitbucket - git rejected push non-fast-forward

I am quite new to git, and I had been working on a small side project for the last 2 months and had been pushing stuff onto bitbucket with no problems. A couple of days ago, I zipped my project folder (since I had to reinstall my Linux OS) and now unzipped this after my reinstallation of Linux OS.

So, now, I went to my project folder, kept happily working and finally did:

git add -A && git commit -m "modified code" && git push origin master

..which is what I usually do..

and I get:

To https://johnsproject@bitbucket.org/johnsproject/proj.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://johnsproject@bitbucket.org/johnsproject/proj.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.

I have had a look at a few SO questions where they suggest the use of a force flag -f - but I am unsure if I should be doing this.

p.s: I am on the master branch - which is the only branch on my repo.

Would really appreciate if anyone could point me in the right direction here.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are changes in the central repository that you must pull before you can push. Do

git add -A
git commit -m "my local changes" 
git pull

Resolve any conflicts. Then do

git push

Alternatively, if you have no valuable modifications locally, you can create a new clone of your repo, and start working from there:

git clone https://johnsproject@bitbucket.org/johnsproject/proj.git new_repo_dir

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...