[英]On Branch master git status is showing nothing to commit (create/copy files and use "git add" to track)
I would like to commit but, whenever I am entering git commit -a -m "Initial commit. Added a gitignore file and a README file.我想提交但是,每当我输入 git commit -a -m "Initial commit。添加了一个 gitignore 文件和一个 README 文件。
Git status showing as Nothing to commit ((create/copy files and use "git add" to track) Git 状态显示为没有提交((创建/复制文件并使用“git add”进行跟踪)
Git init
git add .
git commit -----------------
Where am I lacking?我哪里欠缺? Thanks in advance.
提前致谢。
nothing to commit (create/copy files and use "git add" to track)
That means you are in a brand new local repo, with no file in it.这意味着您在一个全新的本地存储库中,其中没有文件。
You need to add files in that folder first, then you can add and commit.您需要先在该文件夹中添加文件,然后才能添加和提交。
The full sequence would be:完整的顺序是:
git init mynewrepo
cd mynewrepo
git remote add origin https://github.com/<user>/mynewrepo
# write files (README, LICENCE, ...)
git add .
git commit -m "work"
git push -u origin master
Note that, as an alternative, you can create a new repository on GitHub side, directly with a README.请注意,作为替代方案,您可以直接使用 README 在 GitHub 端创建一个新存储库。
Once that is done, you can clone it:完成后,您可以克隆它:
git clone https://github.com/<user>/mynewrepo
cd mynewrepo
# add other files
git add .
git commit -m "work"
git push -u origin master
You have to commit a file !你必须提交一个文件! If you try too commit a repository you'll have this error :"nothing to commit (create/copy files and use "git add" to track)" too.
如果您也尝试提交存储库,则会出现此错误:“无需提交(创建/复制文件并使用“git add”进行跟踪)”。 If you want to create a empty repository you have to create a file.gitkeep in your repository.
如果你想创建一个空的仓库,你必须在你的仓库中创建一个 file.gitkeep。
If in someone's case even after using git add .
如果在某人的情况下,即使在使用
git add .
this problem persists, then this may be useful.这个问题仍然存在,那么这可能有用。
For people like me working on python, if you are creating virtual environment using对于像我这样在 Python 上工作的人,如果您正在使用创建虚拟环境
virtualenv .
in the same folder, then it will automatically modify .gitignore file and hence it will look like:在同一个文件夹中,然后它会自动修改.gitignore文件,因此它看起来像:
# created by virtualenv automatically
*
Which is may be the source of problem in many cases.在许多情况下,这可能是问题的根源。 Removing * may solve problem.
删除 * 可能会解决问题。
Conclusion: Try checking your .gitignore file结论:尝试检查您的.gitignore文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.