fatal: This operation must be run in a work tree git error git使用常见问题汇总(三)


 

git 错误 fatal: This operation must be run in a work tree  

由于git init –bare 方法创建一个裸仓库,在该仓库无法进行任何git操作,所以抛出错误.
解决方法:在该仓库目录下,新建文件夹,进入该文件夹,执行如下命令:
1. touch Readme
2. git init
3. git add Readme
4. git commit -m 'initial commit' Readme

本地操作: (git  commit  push 前 ,必须要  pull )

mkdir   newFord 

git init –bare 
touch Readme
git init
git add Readme
git commit -m 'initial commit' Readme

github操作:

创建 Repositories 

 

fatal: refusing to merge unrelated histories

解决方案

在你操作命令后面加--allow-unrelated-histories
例如:
git merge master --allow-unrelated-histories

如果你是git pull或者git pushfatal: refusing to merge unrelated histories
同理:
git pull origin master --allow-unrelated-histories
等等,就是这样完美的解决咯!

删除git库中untracked files(未监控)的文件

# 删除 untracked files
git clean -f

 
# 连 untracked 的目录也一起删掉
git clean -fd

 
# 连 gitignore 的untrack 文件/目录也一起删掉 (慎用,一般这个是用来删掉编译出来的 .o之类的文件用的)
git clean -xfd

git  commit  modified content, untracked content

git commit    别人的代码后,不能 commit  解决办法:

删除 .git  文件夹   rm  -rf  .git

解决方法:

这个是因为git commit的时候是:git commit -m “xxxx”

改成:git commit -am “xxxx”再git push origin master 就可以了

 

 

解决: rejected master -> master (non-fast-forward)

git push -f origin master

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值