解决git status 后出现了的modified content, untracked content, new commit

项目场景:

clone git中的仓库后,程序员对代码进行本地修改后上传


问题描述

其实主要是git commit 之后无法连接远程仓库,git push总是出错

出错提示是:

remote: rejected by xxx
remote: Push rejected.
+ 小熊 error

然后我就开始了找错误的环节

git status 后出现了
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:  Folder1(modified content)
        modified:  Folder2 (untracked content)
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        file1
no changes added to commit (use "git add" and/or "git commit -a")

原因分析:

我猜是我前一次对文件修改的内容没有提交,同时也没有删除而导致的


解决方案:

1. Folder1 (modified content)
跟踪到Folder1
输入

git status .
//这里一定要加 空格 .
//相当于git status ./xxx/   我因为没有 . 好几次遍历全局(果然是小白)
//git status 命令用于查看在你上次提交之后是否有对文件进行再次修改。

git restore <file>...
//然后把自己不要的文件删掉

删除 untracked files
git clean -f

2.(untracked files)
删除 untracked files
git clean -f

参考Git status时处理Untracked files(未跟踪文件)
https://blog.csdn.net/m0_48283915/article/details/113880123?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&utm_relevant_index=1

2.(new commit )
git submodule update -f .

other:

最开始
git push 时出现了一个问题,忘记了,然后提示用下面的解决

git push --set-upstream origin XXX
# origin 是默认的远程版本库名称 
# 当前分支没有与远程分支关联。
# 根据提示就好啦

如果有其它问题,可以先git pull 然后再 git push

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值