简体   繁体   中英

Git: Your branch is 1 commit ahead and 5 commit behind master?

I am working on a open source project.I first forked the project, cloned it into my machine and have made a change on the master branch directly. I committed those changes and pushed it to my fork. I then opened up a pull request for that change. Whenever I go to my GitHub it I am 1 commit ahead and 5 commit behind the main repository.

How do i solve this issue so that: I have those changes that is made in the master(original) and my changes in my local machine and my forked repository along with the changes that i have made.

git pull with --rebase parameter is better option in this situation.

git pull --rebase origin your_sync_branch

You have unpublished commit. So first rewind them on top of remote master, and then push them to master or other branch:

git push --force-with-lease origin your_banch

Option --force-with-lease first check if on one changed status of remote branch.

You won't be able to push anything until you're up-to-date with the commits you're behind.

git pull is the classic way to fetch new refs from remote then merging to your branch.

When this is done you'll be able to push, it will allow you to do your pull request and get the new changes on the remote main branch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM