The code on Github and the local code are out of sync, how to solve it?
高洛峰
高洛峰 2017-05-02 09:33:16
0
9
733

Because sometimes there is no Internet connection locally, and then after accidentally submitting the new file code to github, the files seem to be marked as submitted the next time they are submitted (actually they are not submitted), and then the github and local codes are not Sync

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(9)
迷茫

No way.

My steps are usually like this
git pushgit push
如果失败的话,说明网络上的版本已经更改过了,那就
git pull
如果失败的话,说明网络的版本和本地的版本在合并时可能产生冲突,那就
git stash(把本地的修改全部缓存起来)
然后再
git pull
然后再
git stash pop(把缓存起来的修改恢复)
然后如果有冲突解决冲突,没有就
git pushIf it fails, it means that the version on the network has been changed, then

git pull

If it fails, it means The network version and the local version may conflict when merging, then

git stash (cache all local changes)🎜and then 🎜git pull🎜then Then 🎜git stash pop(restore the cached changes)🎜Then if there is a conflict, resolve the conflict, if not, just 🎜git push🎜 🎜Use Turtle’s Git tool under Windows. 🎜
phpcn_u1582

Execute as needed

git pull 
git push origin master
阿神

How can I submit it to github without local network?

Ty80

= = Is the submission you are talking about a commit?

If it is a commit, there is no problem, because the commit is to submit the code to the local warehouse

For example, when you don’t have internet

//改了一些文件
git commit -am 'fix a bug'

//又改了一些文件
git commit -am 'add new func'

These changes are all submitted to the local repository, but the remote repository remains unchanged
wait until you have internet access

git push

At this time, the remote warehouse will be compared with your local warehouse, and then the changes will be pushed to the remote warehouse.
The remote warehouse will also have these two commit records at this time.
'fix a bug'
'add new func'

Recommend you to read git tutorial

黄舟

When there is no network, it is submitted to its own local library. If you submit to the remote library, you need to git push

小葫芦

If you are very sure that it is not because someone else updated that your request cannot be completed, but because the last submission caused a problem with the remote version library due to network reasons (unlikely), and you are very sure that the local library is No problem, you can:

git push origin master:master --force
黄舟

commit is in the local warehouse and needs to be pulled up

PHPzhong

I think so, git and github are two different concepts. I understand that you submitted it to the local version control management without an Internet connection, but did not push to the version control of the remote server. Git is distributed version control, that is, a complete version library is maintained remotely and locally. If you connect to the Internet to pull the code, you will pull the code from the server and merge it into the local branch. If you use fetch, you need to check whether you have merge remote branches.

Peter_Zhu

First of all, let’s distinguish what is Git and what is Github.

Then, the Git commit will not be pushed to the remote library. Could it be that you used SVN before?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template