有没有办法可以隐藏我的分阶段变化?我遇到问题的情况是,我在给定时间处理了几个错误,并且有几个未分阶段的更改.我希望能够单独存档这些文件,创建我的.patch文件,并将它们存放起来,直到代码被批准为止.这样,当它被批准时,我可以存储我的整个(当前)会话,弹出该错误并推送代码.
我是以错误的方式来做这件事的吗?我是否误解了git如何以其他方式工作以简化我的流程?
什么时候应该使用git stash save而不是git stash push反之亦然?
在我的Windows机器git stash上每次调用都有大约3.5秒的开销,这为我的git commit hook添加了大约7秒.
linux(同一台机器)下的相同命令大约需要0.01秒.性能问题也适用于空存储库.
core.fscache 被设置为 truecore.preloadindex 被设置为 truegc.auto 被设置为 256运行 GIT_TRACE=true git stash list
16:58:16.844591 git.c:563 trace: exec: 'git-stash' 'list'
16:58:16.844591 run-command.c:336 trace: run_command: 'git-stash' 'list'
16:58:19.699591 git.c:350 trace: built-in: git 'rev-parse' '--git-dir'
16:58:19.859591 git.c:350 trace: built-in: git 'rev-parse' '--git-path' 'objects'
16:58:20.069591 git.c:350 trace: built-in: git 'rev-parse' '--show-toplevel'
16:58:20.154591 git.c:350 trace: built-in: git 'rev-parse' '--git-path' 'index'
16:58:20.244591 git.c:350 trace: built-in: git 'config' …Run Code Online (Sandbox Code Playgroud) 在允许用户提交之前,我们目前正在使用 git hook(如下)在我们的源代码上运行 astyle。这有一个警告,即用户必须提交,格式化他们的代码,然后再次提交,这有点麻烦。理想情况下,我们希望钩子格式化代码,然后将格式化的代码包含在原始提交中。我试过重新添加更改的文件,但它会导致引用错误(显然)。我还尝试在 pre-commit 挂钩中获取历史记录,并尝试退出挂钩并重新运行 git commit 命令,但没有成功。
# Run astyle on changed .cs files, ignoring $ignored
res=$(exec git diff --cached --name-only | \
grep -Ev $ignored | \
xargs astyle --options=conf/astylerc | \
tail -n 1)
num_formatted=$(echo $res | cut -b 1) # We are only interested in the number preceeding 'formatted'.
[[ $num_formatted -ne 0 ]] && echo "WARNING: Code has been automatically formatted. Please re-add and re-commit" && exit 1 || echo "No code to format! …Run Code Online (Sandbox Code Playgroud) 我在错误的分支()上对代码做了一些更改dev。我想将所有更改转移到master分支,我从这里得到了一些线索,但我不清楚git stash存储是否仅暂存文件,甚至是未暂存和未跟踪的文件?
因为,切换分支后,我需要将未暂存和未跟踪的文件提交到master分支上。
分支机构状态dev:
\xe2\x9d\xaf git status\nOn branch dev\nYour branch is up to date with \'origin/dev\'.\n\nChanges not staged for commit:\n (use "git add <file>..." to update what will be committed)\n (use "git restore <file>..." to discard changes in working directory)\n modified: __init__.py\n modified: src/App.py\n modified: src/analysis/insis.py\n modified: src/access/via/db.py\n modified: src/process/DM.py\n modified: start.sh\n modified: utility/utils.py\n\nUntracked files:\n …Run Code Online (Sandbox Code Playgroud)