主目录中的 Git Init - 现在无法提交更改 [英] Git Init in home directory - now unable to commit changes
问题描述
这里是 Git noob,这是我第一次在 bash 上使用 git,我在我的主目录中执行了 git init.我意识到这是错误的,然后使用 rm -rf $HOME/.git 撤消它.
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.
现在,当我尝试在另一个名为 git-practice 的目录中提交更改时,它说分支主并且不会提交我添加到暂存区的任何文件.
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.
当我尝试 git add 时,终端中出现以下内容:
When I try git add, the following comes up in the terminal:
在分支master上
初始提交
未跟踪的文件:(使用git add ..."包含在将要提交的文件中)
Untracked files: (use "git add ..." to include in what will be committed)
自述文件
没有添加任何提交但存在未跟踪的文件(使用git add"进行跟踪)
nothing added to commit but untracked files present (use "git add" to track)
我很困惑,我该如何解决这个问题?
I am confused, how do I fix this?
推荐答案
首先请使用git rev-parse --show-toplevel
检查输出是否为git-practice
目录.如果是,则表示您正在处理此存储库.
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.
然后使用 git-practice
文件夹中的 git repo.您可以使用 git add README.txt
或 git add .
将新文件 README.txt 设为暂存.最后使用 git commit -m 'message'
提交更改.
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.
这篇关于主目录中的 Git Init - 现在无法提交更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!