问题
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