在工作的前两个小时内,我能够轻松地使用git add
指令添加文件,但突然间无法添加其中一个文件。
Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ git add .
Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
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)
modified: app/Http/Controllers/API/AuthController.php
no changes added to commit (use "git add" and/or "git commit -a")
我已经尝试了很多方法来添加但都没有成功:
git add .
git add <path-to-file>
git add -f <path-to-file>
git add --all
git commit -a
所以我还检查了是否有子模块(如果没有我也不知道)。但似乎我也没有这些子模块。 为了找到它们,我执行了以下操作:
git config --file .gitmodules --name-only --get-regexp path
grep path .gitmodules | sed 's/.*= //'
git submodule status --recursive
.
我还查看了
.gitignore
文件,但这仍然是默认的 Laravel 5.3
的文件。
git diff
显示了文件所做的更改,就像平常一样。Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ git diff
diff --git a/app/Http/Controllers/API/AuthController.php b/app/Http/Controllers/API/AuthController.php
index 9bfe453..5add519 100644
--- a/app/Http/Controllers/API/AuthController.php
+++ b/app/Http/Controllers/API/AuthController.php
@@ -65,7 +65,12 @@ class AuthController extends \App\Http\Controllers\Controller {
public function register(Request $request) {
$this->validate($request, [
- 'email' => 'unique:users,email'
+ 'email' => 'unique:users,email',
+ 'first_name' => 'required|min:2|max:255',
+ 'last_name' => 'required|min:2|max:255',
+ 'password' => 'required|min:2|max:255',
+ 'avatar' => 'required',
+ 'birthdate' => 'required',
]);
.gitattributes
和 Laravel 的默认设置并没有什么不同。
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
没有嵌套的代码库:
Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ find -name .git
./.git
git add -p
命令将输出以下内容。
Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ git add -p
diff --git a/app/Http/Controllers/API/AuthController.php b/app/Http/Controllers/API/AuthController.php
index 9bfe453..5add519 100644
--- a/app/Http/Controllers/API/AuthController.php
+++ b/app/Http/Controllers/API/AuthController.php
@@ -65,7 +65,12 @@ class AuthController extends \App\Http\Controllers\Controller {
public function register(Request $request) {
$this->validate($request, [
- 'email' => 'unique:users,email'
+ 'email' => 'unique:users,email',
+ 'first_name' => 'required|min:2|max:255',
+ 'last_name' => 'required|min:2|max:255',
+ 'password' => 'required|min:2|max:255',
+ 'avatar' => 'required',
+ 'birthdate' => 'required',
]);
$request->only($this->user_fillable);
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]?
回答 y
时,文件会被添加到索引中。
git add -p
为什么有效,而上述所有其他方法均无效?
编辑:
我尝试再次提交一些更改,但我发现了一些新问题。 Git
似乎认为在app/Http/Controllers/
下有两个文件夹,即Api
和API
,但实际只有API
一个。
大约1000个提交之前,我将文件夹名从Api
更改为API
,因为我的上级要求这样做。这可能是问题的起源吗?
Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ gs
On branch develop
Your branch is up-to-date with 'origin/develop'.
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)
modified: app/Http/Controllers/API/AuthController.php
modified: app/Http/Controllers/Api/AuthController.php
git add
命令时,Git 会说什么? - zhm.gitignore
规则适用于所讨论的文件? - domssongit add -p
确实会识别更改。如果您回答y
(是),文件最终会被添加到索引中吗? - mkrieger1