Git Init in home directory - now unable to commit changes

孤者浪人 提交于 2021-01-20 12:41:07

问题


Git noob here, it's my first try with git on bash, and I did git init in my home directory. I realised that was wrong and then used rm -rf $HOME/.git to undo it.

Now when I try to commit changes in another directory called git-practice, it says branch master and won't commit any files I have added to the staging area.

When I try git add, the following comes up in the terminal:

On branch master

Initial commit

Untracked files: (use "git add ..." to include in what will be committed)

README.txt

nothing added to commit but untracked files present (use "git add" to track)

I am confused, how do I fix this?


回答1:


First, please use git rev-parse --show-toplevel to check if the output is git-practice directory. If it is, that means you are working on this repo.

Then work with the git repo in git-practice folder. You can use git add README.txt or git add . to make the new file README.txt as staged. Finally use git commit -m 'message' to commit the changes.



来源:https://stackoverflow.com/questions/43309860/git-init-in-home-directory-now-unable-to-commit-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!