标签: git-commit

Git:如何将上次提交后的更改移动到新分支

我一直在研究一个我们称之为"A"的分支.我刚刚意识到自从我上次提交以来我添加的代码应该是在特定的(实验性)分支中,而不是在"A"中.如何将更改提交到新分支并将分支"A"保留为上次提交时的状态?

git branch checkout git-checkout git-commit

11
推荐指数
2
解决办法
1460
查看次数

在提交之前如何通过您的暂存文件进行grep?

所以在运行之前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搜索,但我宁愿拥有编程能力来浏览我的分段文件.)

git grep commit git-commit

11
推荐指数
2
解决办法
1887
查看次数

Git提交样式:一次更改所有文件或一次更改一个文件?

我通过一次提交许多文件来保存我的工作.我想知道为每个文件提交是否会更好,但这看起来好多了.

我对现在的方式没有任何问题,但我打算将我的代码放在GitHub上,我希望它易于理解.

我想知道你们其他人使用git是做什么的.如果你能为我拼出来的话.我是Git的新手,我一直在Windows中使用TortoiseGit和gitk.

git version-control git-commit

11
推荐指数
2
解决办法
2297
查看次数

如何使用git interactive rebase签署一系列提交

我想我已经完成并想要发送到上游项目的分支上签署所有提交(例如,通过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)

如何在一个非交互式命令中自动执行此操作?

git git-rebase git-commit

11
推荐指数
2
解决办法
3170
查看次数

git commit --amend是如何工作的?

在独立的HEAD状态下看过GIT commit --amend.这个问题要求答案比需要的要复杂得多.我想了解git commit --amend在正常HEAD情况下​​的工作原理.

git git-amend git-commit

11
推荐指数
2
解决办法
3357
查看次数

Git-commit无法打开vim

最近我安装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

git vim bash commit git-commit

11
推荐指数
4
解决办法
8360
查看次数

更改特定提交的提交消息

注:类似的问题,因为这一个,但也有一些重要的变化.

在给定提交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来更改提交消息.我想要的是:

  1. 该函数rewrite-commit-message接受两个参数:和commit_id,和new_commit_message
  2. 没有必要知道旧的提交消息:commit_id知道哪个提交更改
  3. git commit --amend,因为这与旧提交有关(不一定与最近的提交有关)
  4. 不用担心重写历史和主回购:我在一个功能分支工作,我被允许这样做 git push -f
  5. 我想用filter-branch它,但我不知道如何:
    • 将更改应用于特定的承诺:将test在所使用的rewrite-commit-date功能是用来在env-filter,但我不会做env-filter在这里,因为我不希望改变有关提交环境中任何事物,但提交信息.
    • 如何强制提交消息?在 …

git git-amend git-commit git-rewrite-history

11
推荐指数
1
解决办法
3870
查看次数

错误:gpg.format 的值不受支持:ssh

尝试在我的 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 ssh-keys git-commit

11
推荐指数
2
解决办法
8701
查看次数

从 git 历史记录中删除并完全删除提交

我的 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 push github post-commit git-commit

10
推荐指数
2
解决办法
2万
查看次数

Git从别人的叉子里拉出来

我们是两名学生在我们的在线存储库(不同的回购)上工作,这是从一个共同的上游回购分支.

假设其他学生在特定分支上进行了更改,提交并推送到他的回购.

  1. 如何将这些更改提取到我自己的本地存储库中?

  2. 我是否需要提交并将这些更改推送到我的舞台区域?

谢谢!

git git-pull git-push git-commit git-fork

10
推荐指数
2
解决办法
1万
查看次数