gpt4 book ai didi

Git 添加修改后的文件不起作用,除了 -p(补丁)

转载 作者:太空狗 更新时间:2023-10-29 13:01:56 26 4
gpt4 key购买 nike

突然开始工作的头两个小时后,我似乎无法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/ , 这是 ApiAPI .但是只有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

最佳答案

在尝试了很多不同的事情之后,我能够添加更改。

我做了什么:

  • git add -p 将输出提示。
  • 上演这个大块头 [y,n,q,a,d,/,K,j,J,g,e,?]?
  • 我对每个更改都回答了 y,并在文件末尾添加了它。
  • 在此之后,我能够提交推送更改。

谢谢大家的帮助和@mkrieger1用于 git add -p

关于Git 添加修改后的文件不起作用,除了 -p(补丁),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42552432/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com