Troubleshooting misplaced .git directory (nothing

2019-01-14 00:14发布

I started getting this message. No matter what I edit and try to commit, it says there is nothing to commit. Looks like git does not see my working directory and looking somewhere else.

If I run git status it outputs the same:

nothing to commit (working directory clean)

If I create new branch and edit something, then same thing happens. This started happening when I needed to fix merge clashes. When I wanted to merge my one branch with master branch, I had to manually fix it and I needed my files to look exactly as in that branch overwriting master branch those same files. So I added those files and it let me merge it. But then no matter what I change it shows as there is nothing to commit.

What could be done here?

17条回答
再贱就再见
2楼-- · 2019-01-14 00:45

On branch master Problem it is committed already nothing to commit (working directory clean) if faced this problem then just only use the following command

git push -u origin master

or

git reset
git add .
git commit -m "your commit message"
git push -u origin master
查看更多
做个烂人
3楼-- · 2019-01-14 00:48

if .git is already there in your dir, then follow:

  1. rm -rf .git/
  2. git init
  3. git remote add origin http://xyzremotedir/xyzgitproject.git
  4. git commit -m "do commit"
  5. git push origin master
查看更多
唯我独甜
4楼-- · 2019-01-14 00:52

Don't try commiting / adding files. Just run the following 2 commands (:

    git remote add origin http://xyzremotedir/xyzgitproject.git
    git push origin master
查看更多
Root(大扎)
5楼-- · 2019-01-14 00:53

In my case I had previously initialized a git directory where I was trying to create a new one. I just deleted all the old files and started from scratch.

查看更多
地球回转人心会变
6楼-- · 2019-01-14 00:55

Don't use git commit. Skip commit and it will work.

Just do the

git remote add origin 

and

git push
查看更多
登录 后发表回答