当前位置: 动力学知识库 > 问答 > 编程问答 >

osx - Git status only showing newly created files after becoming root

问题描述:

I have an empty repo and cloned it on my local machine.

Next I have created created some files.

When running git status in the terminal (in the project directory), no files show up as user, but when I run it as root they are visible.

I've installed git via the git installer for OSX, installed XCode command line tools, and added git to $PATH.

I'm also using the Atlassian SourceTree app.

Same problem, but when I run this app as root, it sees the new files.

Anybody got an idea of what can be the problem?

Best,

Richard

网友答案:

You should not run git as root user, and you should never ever run git as root user on a project which your normally use as normal user.

Running git as root will create files belonging to root (e.g. .git/index, ...) which your normal user won't be able to update later.

Solution:

  1. run chown to restore the correct ownership
  2. stop using git as root.
网友答案:

Do you have permission as user to view the folder files? sounds like the permissions are for root only

ls -la in terminal will show you the group and owner. If your user is not in the group or not the owner you will not be able to read the folder content.

How to fix?

sudo chmod 655 .

how to verify the problem?

Open terminal as user and try to list the file content. If you can cant see the files change the group or permissions of the folder so everyone (or whoever you choose) can read/write to this folder.

分享给朋友:
您可能感兴趣的文章:
随机阅读: