简体   繁体   中英

Master branch is behind gh-pages branch

The problem is that my master branch is 2 days behind my gh-pages.

Initially I did:

git init
git add .
git commit -m "initial commit"
git checkout gh-pages
git remote add origin https://... 
git subtree push --prefix dist origin gh-pages

Then I committed and pushed changes to this branch several times, but I never pushed any changes to my master branch.

Now after:

git checkout master
git show

I see that on this branch I still see only the initial commit. But I cannot 'git add .' or 'commit' any new files or changes. I see the message that everything is up-to-date.

The question is: how do I update my master branch?

I am pretty new at git, hope for your patience.

In my humble opinion, you shouldn't have rushed into git subtree from the beginning. This is a very particular use case of Git, which is independent from branching system. Moreover, when doing git checkout gh-pages , you try to switch from branch master (by default) to gh-pages , which doesn't exist yet since just have created your repository (using git init ). This should have failed with a error message.

The question is: how do I update my master branch?

In normal conditions, you would have merged the gh-pages branch into the master one, using :

git checkout master
git merge gh-pages

… but I'm pretty sure this is NOT what you'll need to do in your current conditions. In particular, I understand that your local repository was not empty at the beginning but if you have added a remote repository, did this one already exist before ? If yes, and if they was no previous work in your local repository, maybe you should have used git clone instead.

In any case, try to do a

git remote update

… first, to synchronize the state of your local repository with the remote one (this won't affect you working directory).

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