扫码关注官方订阅号
远程仓库有4个文件,本地有5个文件,相当于新增了一个,从远程仓库git pull下来后,会把本地的新增文件给删除了,直接git push又提示版本落后,不能推送到远程仓库,应该如何操作?
先把本地新增的文件commit之后再去合并远程仓库的,具体操作如下:git add .git commit -m "something"git fetchgit rebase -i origin/远程分支名使用rebase可以防止分叉
补充一下。如果当前还不是提交的最终版本,在git commit那步有两种选择。
一个是先stash,rebase之后再git stash apply stash@{0}也可以先commit,然后完成了所有本地更改之后再git commit --amend
git stash apply stash@{0}
git commit --amend
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
先把本地新增的文件commit之后再去合并远程仓库的,具体操作如下:
git add .
git commit -m "something"
git fetch
git rebase -i origin/远程分支名
使用rebase可以防止分叉
补充一下。如果当前还不是提交的最终版本,在git commit那步有两种选择。
一个是先stash,rebase之后再
git stash apply stash@{0}
也可以先commit,然后完成了所有本地更改之后再
git commit --amend