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
fatal: refusing to merge unrelated histories
解决方案
在你操作命令后面加
--allow-unrelated-histories
例如:
git merge master --allow-unrelated-histories
如果你是
git pull
或者
git push
报
fatal: 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