智能git存储和重新设置

时间:2018-10-18 11:32:43

标签: git

在我们的repo中(因为它很大),进行rebase很痛苦,我们都工作自己的master分支,在本地进行提交,获取,rebase,然后push,大多数情况下我们最终都会这样做

git fetch
git stash
git rebase
git stash pop
git push

此过程可能需要30到60秒(大多数情况下是1个命令的别名)

在这段时间内,它确实可以移开键盘,因为如果您触摸任何文件,都可能导致“未按阶段进行的更改”和重新设置失败

人们通常会拥有未暂存文件的工作副本,这些副本尚未成为任何提交的一部分(因此需要隐藏)

如果您使用的是Visual Studio,则会看到Visual Studio询问您是否要重新加载文件(因为它会将文件移开并再次移回)

这有点烦人...而且容易出错。我想知道是否有更好的方法:

  1. 鉴于您刚刚进行了git fetch,您知道 原始/主提交
  2. 您知道自己的HEAD提交
  3. 您认为可能仅可以存储以下文件: 当前提交和 原始/主提交
  4. 感觉没有必要隐藏任何不会存储的文件 需要合并

我还注意到,当存储项将未暂存的文件移开并再次移回(未由重新基准进行修改)时,它将更改文件的修改时间。如果您有一个依赖于依赖项的构建系统,那么它将导致那些被触摸的文件需要重建

所以我的问题:

  1. 是否可以进行有限的存储(仅限受影响的文件)?
  2. 藏匿点弹出是否有可能保留从藏匿它们开始的修改时间?
  3. 有没有更好的工作方式?

非常感谢

其他信息...大部分时间都被藏起来和藏起来了

总藏匿时间= 17:17:52.883984-17:16:34.682266 = 1分钟18秒 总藏匿弹出时间= 17:19:25.326706-17:18:23.357639 = 1分钟2秒

$ GIT_TRACE=true git stash
17:16:34.682266 git.c:576               trace: exec: git-stash
17:16:34.683120 run-command.c:640       trace: run_command: git-stash
17:16:35.392884 git.c:576               trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
17:16:35.394043 run-command.c:640       trace: run_command: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
17:16:35.574243 git.c:576               trace: exec: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
17:16:35.575410 run-command.c:640       trace: run_command: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
17:16:35.902034 git.c:344               trace: built-in: git rev-parse --git-dir
17:16:36.104332 git.c:344               trace: built-in: git rev-parse --git-path objects
17:16:36.499926 git.c:344               trace: built-in: git rev-parse --show-prefix
17:16:36.679648 git.c:344               trace: built-in: git rev-parse --show-toplevel
17:16:36.890647 git.c:344               trace: built-in: git rev-parse --git-path index
17:16:37.083861 git.c:344               trace: built-in: git config --get-colorbool color.interactive
17:16:37.251940 git.c:344               trace: built-in: git config --get-color color.interactive.help 'red bold'
17:16:37.421967 git.c:344               trace: built-in: git config --get-color  reset
17:16:37.594741 git.c:344               trace: built-in: git rev-parse --sq --prefix src/mydir --
17:16:37.779674 git.c:344               trace: built-in: git ls-files --error-unmatch --
17:16:38.055453 git.c:344               trace: built-in: git update-index -q --refresh
17:16:51.868211 git.c:344               trace: built-in: git diff-index --quiet --cached HEAD --ignore-submodules --
17:16:52.292151 git.c:344               trace: built-in: git diff-files --quiet --ignore-submodules --
17:17:05.488052 git.c:344               trace: built-in: git reflog exists refs/stash
17:17:05.679272 git.c:344               trace: built-in: git update-index -q --refresh
17:17:18.769370 git.c:344               trace: built-in: git diff-index --quiet --cached HEAD --ignore-submodules --
17:17:19.147722 git.c:344               trace: built-in: git diff-files --quiet --ignore-submodules --
17:17:32.039258 git.c:344               trace: built-in: git rev-parse --verify HEAD
17:17:32.322507 git.c:344               trace: built-in: git rev-list --oneline -n 1 HEAD --
17:17:32.721850 git.c:344               trace: built-in: git symbolic-ref -q HEAD
17:17:32.963491 git.c:344               trace: built-in: git write-tree
17:17:33.479251 git.c:344               trace: built-in: git commit-tree 2372528ce6a7cf773c3e7df932ea1762f69459e4 -p 270db9ff224e8b7baaa76f3f12dc55cf04dd7c5f
17:17:33.842338 git.c:344               trace: built-in: git read-tree --index-output=.git/index.stash.31348 -m 2372528ce6a7cf773c3e7df932ea1762f69459e4
17:17:35.405659 git.c:344               trace: built-in: git diff-index --name-only -z HEAD --
17:17:50.044073 git.c:344               trace: built-in: git update-index -z --add --remove --stdin
17:17:50.788781 git.c:344               trace: built-in: git write-tree
17:17:51.617735 git.c:344               trace: built-in: git commit-tree 4af893fdd10d58762651befa2bbb8eee71f291ac -p 270db9ff224e8b7baaa76f3f12dc55cf04dd7c5f -p 323f7da91a6ddfe52f0346d3e3fa6506cfde0fbb
17:17:51.938857 git.c:344               trace: built-in: git update-ref --create-reflog -m 'WIP on master: 270db9ff224 Mylastcommit' refs/stash da808c64188e12626e92107d95433f507415e053
17:17:52.380955 git.c:576               trace: exec: git-sh-i18n--envsubst --variables 'Saved working directory and index state $stash_msg'
17:17:52.382510 run-command.c:640       trace: run_command: git-sh-i18n--envsubst --variables 'Saved working directory and index state $stash_msg'
17:17:52.619887 git.c:576               trace: exec: git-sh-i18n--envsubst 'Saved working directory and index state $stash_msg'
17:17:52.621484 run-command.c:640       trace: run_command: git-sh-i18n--envsubst 'Saved working directory and index state $stash_msg'
Saved working directory and index state WIP on master: 270db9ff224 Mylastcommit
17:17:52.883984 git.c:344               trace: built-in: git reset --hard -q

藏匿流行物

$ GIT_TRACE=true git stash pop
17:18:23.357639 git.c:576               trace: exec: git-stash pop
17:18:23.358544 run-command.c:640       trace: run_command: git-stash pop
17:18:25.532417 git.c:576               trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
17:18:25.535394 run-command.c:640       trace: run_command: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
17:18:26.782965 git.c:576               trace: exec: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
17:18:26.786540 run-command.c:640       trace: run_command: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
17:18:30.387292 git.c:344               trace: built-in: git rev-parse --git-dir
17:18:30.846062 git.c:344               trace: built-in: git rev-parse --git-path objects
17:18:31.444631 git.c:344               trace: built-in: git rev-parse --show-prefix
17:18:31.688101 git.c:344               trace: built-in: git rev-parse --show-toplevel
17:18:31.958273 git.c:344               trace: built-in: git rev-parse --git-path index
17:18:32.214299 git.c:344               trace: built-in: git config --get-colorbool color.interactive
17:18:32.505740 git.c:344               trace: built-in: git config --get-color color.interactive.help 'red bold'
17:18:32.894387 git.c:344               trace: built-in: git config --get-color  reset
17:18:33.251394 git.c:344               trace: built-in: git rev-parse --verify --quiet refs/stash
17:18:33.571029 git.c:344               trace: built-in: git rev-parse --symbolic --verify --quiet 'refs/stash@{0}'
17:18:33.883359 git.c:344               trace: built-in: git rev-parse --verify --quiet 'refs/stash@{0}^2'
17:18:34.655407 git.c:344               trace: built-in: git rev-parse --symbolic-full-name refs/stash
17:18:34.842979 git.c:344               trace: built-in: git rev-parse --verify --quiet 'refs/stash@{0}^3'
17:18:35.180608 git.c:344               trace: built-in: git update-index -q --refresh
17:18:50.084605 git.c:344               trace: built-in: git write-tree
17:18:50.728293 git.c:344               trace: built-in: git merge-recursive 2372528ce6a7cf773c3e7df932ea1762f69459e4 -- 2372528ce6a7cf773c3e7df932ea1762f69459e4 4af893fdd10d58762651befa2bbb8eee71f291ac
17:18:53.083985 git.c:344               trace: built-in: git diff-index --cached --name-only --diff-filter=A 2372528ce6a7cf773c3e7df932ea1762f69459e4
17:18:53.875222 git.c:344               trace: built-in: git read-tree --reset 2372528ce6a7cf773c3e7df932ea1762f69459e4
17:18:55.686552 git.c:344               trace: built-in: git update-index --add --stdin
17:18:56.025110 git.c:344               trace: built-in: git status
On branch master
Your branch is up to date with 'origin/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)

        modified:   ....
        ....

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        ....


It took 13.53 seconds to enumerate untracked files. 'status -uno'
may speed it up, but you have to be careful not to forget to add
new files yourself (see 'git help status').
no changes added to commit (use "git add" and/or "git commit -a")
17:19:24.442842 git.c:344               trace: built-in: git reflog delete --updateref --rewrite 'refs/stash@{0}'
17:19:24.783530 git.c:576               trace: exec: git-sh-i18n--envsubst --variables 'Dropped ${REV} ($s)'
17:19:24.785203 run-command.c:640       trace: run_command: git-sh-i18n--envsubst --variables 'Dropped ${REV} ($s)'
17:19:25.045532 git.c:576               trace: exec: git-sh-i18n--envsubst 'Dropped ${REV} ($s)'
17:19:25.047257 run-command.c:640       trace: run_command: git-sh-i18n--envsubst 'Dropped ${REV} ($s)'
Dropped refs/stash@{0} (da808c64188e12626e92107d95433f507415e053)
17:19:25.326706 git.c:344               trace: built-in: git rev-parse --verify --quiet 'refs/stash@{0}'

Total Stash Pop Time = 17:19:25.326706 - 17:18:23.357639 = 1 minutes, 2 seconds

最近一次更新时,我意识到花了3-4分钟来完成完整的隐藏/重置/弹出

我什至在使用新的内置rebase和stash来尝试加快速度

https://github.com/git-for-windows/git/pull/1800和git v2.20

[rebase]
    useBuiltin = true
[stash]
    useBuiltin = true

和其他最佳做法

(例如,我的磁盘是SSD)

[core]
    preloadindex = true
    fscache = true

0 个答案:

没有答案