我的项目包含多个包package_a/
和package_b/
。每个包在适当的子目录中包含一个或两个类。我对主分支上存在的这两个包都没问题。但是,当我执行以下程序时遇到麻烦:
我添加,提交并将package_a/
推送到主分支。当我在推动期间输入git push -u origin master
时,我被推向上游(我相信这是一个术语)。这在我登录我的github帐户时反映出来。到目前为止一切都很棒。
我添加了package_b /。在添加package_b /之后但在提交和推送之前,我进入目录并看到一堆已添加的文件,这是预期的,因为它包含包含类的子目录和 init 。 py文件。但是,我还看到一个已修改内容的子目录,因此没有为提交暂存更改。
本质:
new file: package_b/__init__.py
new file: package_b/class_b
Changes not staged for commit:
modified: package_b/class_b
我怎么能修改内容,因为我还没有在package_b中提交任何内容?如果相关,package_a不会从package_b导入任何内容,反之亦然。
git非常新,并试图尽早建立好的做法。我很感激您的反馈!
Git如下所示:
Peter Altamura@AltamuraDesktop MINGW64 /f/liteSaber (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
containers/
nothing added to commit but untracked files present (use "git add" to track)
Peter Altamura@AltamuraDesktop MINGW64 /f/liteSaber (master)
$ git checkout -b gd_api
Switched to a new branch 'gd_api'
Peter Altamura@AltamuraDesktop MINGW64 /f/liteSaber (gd_api)
$ git add containers/
Peter Altamura@AltamuraDesktop MINGW64 /f/liteSaber (gd_api)
$ git status
On branch gd_api
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: containers/__init__.py
new file: containers/base_obj.py
new file: containers/game/__init__.py
new file: containers/game/game.py
new file: containers/gameday
new file: containers/player/__init__.py
new file: containers/player/player.py
new file: containers/player/team.py
new file: containers/toolkit/__init__.py
new file: containers/toolkit/reference.py
new file: containers/toolkit/tools.py
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: containers/gameday (modified content, untracked content)
$ find -name .git
./。GIT中
./容器/ git的
./容器/比赛日/ git的
答案 0 :(得分:1)
git status
向您显示的是您本地目录中的内容与您上演的内容之间的更改。所以它看起来像class_b
添加git add
(但没有提交),然后以某种方式更改class_b
。所以这告诉你的是,如果你运行git commit
,那么在你调用class_b
时,只会提交git add
的内容。
请注意,git add
不仅用于向存储库添加新文件,还用于将更改添加到现有文件到存储库(或者更准确地说,覆盖现有文件)索引中的文件与本地副本)。鉴于它的作用,它不是最好的命令。