主目录中的Git Init-现在无法提交更改 [英] Git Init in home directory - now unable to commit changes

查看:56
本文介绍了主目录中的Git Init-现在无法提交更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是Git菜鸟,这是我第一次尝试在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的目录中提交更改时,它表示分支master,并且不会提交我已添加到暂存区的任何文件.

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:

在分支机构主管上

初始提交

未跟踪的文件:(使用"git add ..."包含在将要提交的文件中)

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

README.txt

README.txt

未添加任何内容来提交但存在未跟踪的文件(使用"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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆