经过前两个小时的突然工作,我似乎无法找到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")
Run Code Online (Sandbox Code Playgroud)
如果添加方法没有成功,我已经尝试了很多:
git add .git add <path-to-file>git add -f <path-to-file>git add --allgit commit -a所以我也检查过我是否有子模块(没有我知道它).我似乎也没有那些.找到他们我做了:
git config --file .gitmodules --name-only --get-regexp pathgrep 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',
]);
Run Code Online (Sandbox Code Playgroud)
.gitattributes 并没有显示与Laravel默认值有任何不同.
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
Run Code Online (Sandbox Code Playgroud)
没有嵌套的存储库:
Casper@PC2015 MINGW64 /c/Workspace/edoping (develop)
$ find -name .git
./.git
Run Code Online (Sandbox Code Playgroud)
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,?]?
Run Code Online (Sandbox Code Playgroud)
响应时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
Run Code Online (Sandbox Code Playgroud)
在尝试了很多不同的事情后,我能够添加更改.
我做了什么:
git add -p 这将输出提示.Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]?.y了每一个更改,在文件的最后,它被添加了.commit和push变化.谢谢大家的帮助和@ mkrieger1的加入git add -p