我一直在研究一个我们称之为"A"的分支.我刚刚意识到自从我上次提交以来我添加的代码应该是在特定的(实验性)分支中,而不是在"A"中.如何将更改提交到新分支并将分支"A"保留为上次提交时的状态?
所以在运行之前git commit我经常运行以下内容:
git grep --cached -l -I "debugger"
Run Code Online (Sandbox Code Playgroud)
我认为它类似于:
git diff --cached
Run Code Online (Sandbox Code Playgroud)
(它将显示您即将提交的所有更改,即将显示您的暂存文件中的差异).
不幸的是,我刚刚发现这个--cached选项git grep只是告诉git"只"查看其索引中的所有内容.
那么我怎样才能运行git grep并让它只通过我的分阶段文件?
(是的,我知道我可以简单地进行git diff --cached搜索,但我宁愿拥有编程能力来浏览我的分段文件.)
我通过一次提交许多文件来保存我的工作.我想知道为每个文件提交是否会更好,但这看起来好多了.
我对现在的方式没有任何问题,但我打算将我的代码放在GitHub上,我希望它易于理解.
我想知道你们其他人使用git是做什么的.如果你能为我拼出来的话.我是Git的新手,我一直在Windows中使用TortoiseGit和gitk.
我想在我已经完成并想要发送到上游项目的分支上签署所有提交(例如,通过GitHub上的pull请求).
我发现的推荐方法是使用
git rebase -i [base-commit]
# Set all commits to "edit"
git commit --amend --signoff # do this for all commits
Run Code Online (Sandbox Code Playgroud)
如何在一个非交互式命令中自动执行此操作?
我在独立的HEAD状态下看过GIT commit --amend.这个问题要求答案比需要的要复杂得多.我想了解git commit --amend在正常HEAD情况下的工作原理.
最近我安装bash-it到我的终端.现在,当我尝试执行git commit终端时显示我的错误:
/usr/bin/mate -w: /usr/bin/mate: No such file or directory
error: cannot run /usr/bin/mate -w: No such file or directory
error: There was a problem with the editor '/usr/bin/mate -w'.
Please supply the message using either -m or -F option.
之前bash-it,commit命令正确打开了vim.当然我已经尝试将core.editorin git 更改为"vim",但无论如何它都无法正常工作.
你能帮我解决这个问题吗?我非常喜欢vim,它非常简单快速...我不想使用TextMate来编辑提交消息.
PS:我正在使用Mac OSX
注:类似的问题,因为这一个,但也有一些重要的变化.
在给定提交ID的情况下,我有以下函数来重写提交的日期:
rewrite-commit-date () {
local commit="$1"
local newdate="$2"
newdate="$(date -R --date "$newdate")"
echo ">>>> Rewriting commit $commit date: $newdate"
git filter-branch --env-filter \
"if test \$GIT_COMMIT = '$commit'
then
export GIT_AUTHOR_DATE
export GIT_COMMITTER_DATE
GIT_AUTHOR_DATE='$newdate'
GIT_COMMITTER_DATE='$newdate'
fi" &&
rm -fr "$(git rev-parse --git-dir)/refs/original/"
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试实现类似的功能rewrite-commit-message来更改提交消息.我想要的是:
rewrite-commit-message接受两个参数:和commit_id,和new_commit_messagecommit_id知道哪个提交更改git commit --amend,因为这与旧提交有关(不一定与最近的提交有关)git push -ffilter-branch它,但我不知道如何:
test在所使用的rewrite-commit-date功能是用来在env-filter,但我不会做env-filter在这里,因为我不希望改变有关提交环境中任何事物,但提交信息.尝试在我的 Debian 机器上设置 git commit 签名。我已经在我的 Windows 盒子上安装了这个设置,并且运行良好。我的 Debian 盒子上没有那么多。当我尝试提交时出现以下错误:
siggib@htzn:/var/www/phpdemo$ git commit -m "tweak"
error: unsupported value for gpg.format: ssh
fatal: bad config variable 'gpg.format' in file '/home/siggib/.gitconfig' at line 6
Run Code Online (Sandbox Code Playgroud)
这是我的配置的样子
siggib@htzn:/var/www/phpdemo$ git config --list
user.name=siggib@htzn
user.email=siggib007@users.noreply.github.com
user.signingkey=ssh-ed25519 AAAAC3NzaC.....
gpg.format=ssh
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/siggib007/phptest.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
siggib@htzn:/var/www/phpdemo$
Run Code Online (Sandbox Code Playgroud)
我尝试用谷歌搜索这个,但没有发现任何有用的东西,也尝试在这里搜索,得到相同的结果。有人对我有什么好的指点吗?
我的 git 历史中有一个提交
1.commit 4930da17d8dd23d650ed38435d8b421816a0c451
Date: Sat Dec 5 14:34:18 2015 +0530
2.commit e1ebbbb599ee20ebec3ca92c26266d9fd16e7ccc
Date: Sat Dec 5 13:22:20 2015 +0530
3.commit 1c4a11a80eb054d24dafec2efed0b0282188e687
Date: Sat Dec 5 12:11:50 2015 +0530
4.commit b4ab3c164a3a8d93e0a71a94b5c561cb5e20ebf6
Date: Sat Dec 5 12:09:56 2015 +0530
5.commit 167b1d10258381f09663ce61fa88ce3bbcd404c4
Date: Sat Dec 5 12:09:21 2015 +0530
6.commit c61bcadac673e1c83f4c14b66d56e23b12fa3198
Date: Sat Dec 5 12:07:58 2015 +0530
Run Code Online (Sandbox Code Playgroud)
在第三次和第四次提交中包含错误的代码,但我在不知不觉中提交并推送了。
3.commit 1c4a11a80eb054d24dafec2efed0b0282188e687
Date: Sat Dec 5 12:11:50 2015 +0530
4.commit b4ab3c164a3a8d93e0a71a94b5c561cb5e20ebf6
Date: Sat Dec 5 12:09:56 2015 +0530
Run Code Online (Sandbox Code Playgroud)
但第五次和第六次提交包含正确的代码。我需要这个承诺才能工作。
5.commit 167b1d10258381f09663ce61fa88ce3bbcd404c4
Date: …Run Code Online (Sandbox Code Playgroud) 我们是两名学生在我们的在线存储库(不同的回购)上工作,这是从一个共同的上游回购分支.
假设其他学生在特定分支上进行了更改,提交并推送到他的回购.
如何将这些更改提取到我自己的本地存储库中?
我是否需要提交并将这些更改推送到我的舞台区域?
谢谢!
git ×10
git-commit ×10
commit ×2
git-amend ×2
bash ×1
branch ×1
checkout ×1
git-checkout ×1
git-fork ×1
git-pull ×1
git-push ×1
git-rebase ×1
github ×1
grep ×1
post-commit ×1
push ×1
ssh-keys ×1
vim ×1