在突然工作的前两个小时之后,我似乎无法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
文件,但这仍然是来自.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
。
大约一千次提交我确实将文件夹名称从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
答案 0 :(得分:5)
在尝试了很多不同的事情后,我能够添加更改。
我做了什么:
git add -p
将输出提示。Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]?
。y
,并在文件末尾添加了。commit
和push
进行更改。感谢大家的帮助,@mkrieger1与git add -p