我在一个文件夹中有 4 个文件。我修改了其中的 3 个。如何一次只添加和推送修改过的文件。将“git add”。在这里工作。
我错误地运行了命令
git add -A
Run Code Online (Sandbox Code Playgroud)
然后(当我弄清楚时)我用停止它
Ctrl+C
Run Code Online (Sandbox Code Playgroud)
有没有办法将存储库重置到之前的位置git add -A?
git status显示:
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: 1xx_xx/xx.m~
# modified: 2xx_xx/xx_xx.m
# deleted: 3xx_xx/xx_xx.m~
# modified: 4xx_xx/xx_xx.m
#
# Untracked files:
# (use "git add <file>..." to …Run Code Online (Sandbox Code Playgroud) 我正在使用bitbucket web界面并创建了一个新项目"Test_Project".在这个项目中,我能够使用Create repository选项创建一个新的存储库 - "Module1" .
现在我想在bitbucket项目中创建存储库层次结构 - Test_Project如下: -
Test_Project(Bitbucket项目)
Web(存储库1)
Module1 (Sub-Repository/Sub-module 1)
Module2 (Sub-Repository/Sub-module 2)
Module3 (Sub-Repository/Sub-module 3)
Run Code Online (Sandbox Code Playgroud)移动(存储库2)
Module1 (Sub-Repository/Sub-module 1)
Module2 (Sub-Repository/Sub-module 2)
Module3 (Sub-Repository/Sub-module 3)
Run Code Online (Sandbox Code Playgroud)存档(存储库3)
Module1 (Sub-Repository/Sub-module 1)
Module2 (Sub-Repository/Sub-module 2)
Module3 (Sub-Repository/Sub-module 3)
Run Code Online (Sandbox Code Playgroud)项目文件(知识库4)
等等..
这样我就可以在各自的bitbucket子存储库中添加本地项目
任何人都可以指导如何在bitbucket中的新存储库中创建子存储库/子模块.
在从快照计算变更集时,Git并不总是正确选择块边界.git diff有一个--diff-algorithm选项允许在这方面进行一些调整; git diff --minimal有时比git diff单独给出更好的结果.
有没有办法获得相同的优化变更集布局git add -p(基本上以diff交互方式显示帅哥)?它似乎不允许这个--diff-algorithm选项.
我运行git add了一些文件,构成了一组逻辑上独立的更改,对它们进行了其他更改,并使用git add -p. 进行到一半时,我意识到我还没有提交前一组。
的交互式帮助git add -p仅提供以下选项:
Stage this hunk [y,n,q,a,d,/,s,e,?]? ?
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later hunks in the file
g - select a hunk to go …Run Code Online (Sandbox Code Playgroud) 需要一些帮助!
我知道可以使用reflog等来恢复这些更改,但我不知道怎么做!我知道有可能获得差异.我真的需要这些改变.
有任何想法吗??
我有一个奇怪的情况 - 我的 git 工作正常直到一个小时左右,但现在当我尝试运行时
git add * --all
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息error:known switch `C'。
下面是我得到的输出。我刚刚从有一些更改的存储库中取出,之后我开始收到此错误。尝试了一下,发现错误是由于*符号造成的。如果我删除它,它会起作用......
$ git add * --all
error: unknown switch `C'
usage: git add [options] [--] <pathspec>...
-n, --dry-run dry run
-v, --verbose be verbose
-i, --interactive interactive picking
-p, --patch select hunks interactively
-e, --edit edit current diff and apply
-f, --force allow adding otherwise ignored files
-u, --update update tracked files
-N, --intent-to-add record only the fact that the path will be added …Run Code Online (Sandbox Code Playgroud) 我有这个补丁文件,它包含一堆修改,我想将其应用于git分支。但是,我不想对所有这些修改都进行一次唯一提交,而是想将其分为2或3次提交。
我知道我可以通过首先应用补丁来实现此目的,然后进行交互式添加(逐块),如下所示:
git apply mypatch
git add -p
Run Code Online (Sandbox Code Playgroud)
我只是想知道是否可以在一个git命令中做到这一点。我发现没有什么的联机帮助页git apply,也不在git add。
编辑
我不认为此问题应被视为具有多个命令的Git别名语法的重复,因为该问题(及其答案)不需要涉及传递给别名的参数。
即使在执行 git add -A 之后,当我运行 git status 时,我得到了这个:
# On branch master
# 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: src/cartographer (modified content, untracked content)
# modified: src/cartographer_ros (untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个问题吗?
团队,有没有一种方法可以通过确认一一添加我的所有更改?
例如:如果我更改了 10 个文件,那么应该会提示我 10 次是否添加更改。我不想执行“git add -A”或手动添加每个更改。在添加 git 之前是否有自动提示 y/n 的方法?
git ×10
git-add ×10
bitbucket ×1
diff ×1
git-apply ×1
git-branch ×1
git-patch ×1
git-reflog ×1
git-reset ×1
git-revert ×1
github ×1
terminal ×1
ubuntu ×1