git同步相关问题处理记录


两处的代码git合并,需要解决产生的冲突,我现在初步接触merge的问题,暂且这样记录。

git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:

  1. 保留原来的改动,先将远端代码pull下来然后应用原来的改动
    git stash
    git pull
    git stash pop
    
  2. 不保留原来的改动,直接回退到上一版本再pull
    git reset --hard
    git pull
    

fatal: refusing to merge unrelated histories

在操作命令后面加上--allow-unrelated-histories

Git『Everything up-to-date』问题解决

本来有要提交的代码但却说已经是最新版本了,解决方法是新建一个newbranch分支,将当前分支truebranch要提交的内容先提交到newbranch上,将新分支上的内容合并到truebranch上,再推truebranch的内容到远端仓库,最后删掉新分支。命令:

git branch
git branch newbranch
git branch
git checkout newbranch
git branch
git add .
git commit -m 'message'
git checkout truebranch
git merge newbranch
git diff
git push origin truebranch
git branch -D newbranch

新添的gitignore项在commit中生效

git rm -r --cached .

error: object file is empty

在我git push过程中,主机断电,后来我再次git push,遇到此错误。解决方法,删掉那个空文件,重新提交。删掉空文件后执行git fsck没有遇到报错。

git commit 后报错:Changes not staged for commit

git commit 后报错:Changes not staged for commit 写的内容汇总到这里了。
提交目录中的文件到阿里云的git仓库,使用git add *命令将项目文件的内容提交上去,commit上去报如题所示错误,意即改变无法覆盖。

听网上的人说,出现这种报错的原因是git add *命令没有将文件提交到暂存区,看到这个博客后,试了一下git add ./命令,解决了该报错,仓库的改变提交了上去。
本文创建于2020-10-09 11:01,修改于2022.4.26/13.13

posted @ 2020-10-09 11:01  园糯  阅读(1154)  评论(0编辑  收藏  举报