简体   繁体   English

在 Branch master git status 上没有显示要提交的内容(创建/复制文件并使用“git add”进行跟踪)

[英]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.

相关问题 Git 无法正常工作,无需提交(创建/复制文件并使用“git add”进行跟踪) - Git not working properly nothing to commit (create/copy files and use “git add” to track) git status 在分支 master 初始提交显示未跟踪的文件: - git status On branch master Initial commit shows Untracked files: GIT分支位于前面或原始/主节点没有任何提交 - GIT branch is ahead or origin/master with nothing to commit Git 如何在 master 分支中跟踪修改的文件 - Git how to track modified files in master branch 我怎样才能从git status“在分支主服务器上\\ n什么都没提交..”到“在分支主服务器上\\ n您的分支是最新的\\ n什么都没有..”? - How can i get from git status “On branch master \n Nothing to commit..” to “On branch master \n Your branch is up to date \n Nothing to ..” ?" npm-debug.log位于.gitignore文件中,但我仍然收到消息“没有添加任何内容来提交但存在未跟踪的文件(使用” git add”进行跟踪)” - npm-debug.log is in .gitignore file, but I still get the messsage “nothing added to commit but untracked files present (use ”git add“ to track)” git status说什么也没提交,但是不能切换分支 - git status say nothing to commit, but can't switch branch git 添加。 -> 新文件仍然“没有什么可提交的” - git add . -> still "nothing to commit" with new files Git不添加文件(无需提交) - Git does not add files (nothing to commit) git status --short:缺少“你的分支超过&#39;origin / master&#39;提交1次” - git status --short: missing “Your branch is ahead of 'origin/master' by 1 commit”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM