相关疑难解决方法(0)

签出旧提交并使其成为新提交

在Git上,说我弄乱了我的提交,我想让版本3提交以前作为新版本.如果我这样做git checkout xxxx,它会创建一个新的分支,似乎我只能合并它?我可以把它变成新的"主版"吗?

我想要:

A-B-C-D-E
Run Code Online (Sandbox Code Playgroud)

成为

A-B-C-D-E-F
Run Code Online (Sandbox Code Playgroud)

其中F与C的内容完全相同

如果我使用git revert xxxx,它似乎肯定会有冲突,我需要手动解决它.

我真正想要的只是在某个时刻进行旧提交新的提交,无论我的工作目录或最新的提交是什么.

我该怎么做呢?

git

190
推荐指数
5
解决办法
17万
查看次数

git index.lock我尝试提交时存在文件,但无法删除该文件

当我做'git commit'时,我得到以下内容:

fatal: Unable to create 'project_path/.git/index.lock': File exists.

但是,当我这样做时ls project_path/.git/index.lock,说该文件不存在.我应该怎么做?我也注意到project_path/.git由root拥有,不确定这是否与我遇到的问题有关.

git版本是1.7.5.4

编辑:似乎问题很可能是我运行的另一个进程,即向项目目录编写(我不知道).我重新启动了我的机器然后我没有任何问题.

git

179
推荐指数
12
解决办法
26万
查看次数

git reset - hard origin/master失败

尝试放弃服务器上的更改,并使其与origin/master完全相同:

git fetch --all
git reset --hard origin/master
Run Code Online (Sandbox Code Playgroud)

我之前在同一个repo上做过这个没有问题,但这次它失败了以下:

fatal: Could not reset index file to revision 'origin/master'
Run Code Online (Sandbox Code Playgroud)

尝试了以下内容:

  1. 删除索引并按照此处的建议重置:

    rm .git/index
    git reset
    
    Run Code Online (Sandbox Code Playgroud)
  2. 这里还建议某些进程可以锁定.git\index.杀戮过程然后执行git reset可以解决它,但不知道如何检查某些东西是否远程锁定文件.似乎删除索引文件和重置也会产生相同的效果.

失去理智.非常感谢任何帮助.

git

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

在Windows上坚持Git:无法结账,无法藏匿,无法提交

我被困了......如果我做git stash我得到:

Fatal: Unable to create /index.lock: File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
Run Code Online (Sandbox Code Playgroud)

手动删除index.lock后,我得到:

Rename from .git/index.lock to .git/index failed. Should I try again? (y/n)
Run Code Online (Sandbox Code Playgroud)

git checkout master:

 Rename from .git/index.lock to .git/index failed. Should I try again? (y/n)
Run Code Online (Sandbox Code Playgroud)

git通过GitHub提交:

Unable to create a new commit
Run Code Online (Sandbox Code Playgroud)

我能做什么?

git github

9
推荐指数
1
解决办法
7075
查看次数

Git-Bash for Windows'rm'如何运作?

在某些情况下,rmGit-Bash中的命令会删除在资源管理器,cmd提示符,PowerShell或使用C++标准库调用中无法删除的文件.

为什么?

这让我感到困惑,因为我知道这里没有魔法,我认为它们都使用相同的Win32 API.

例如,我有数据库快照保持打开状态,无法使用所描述的其他方法删除,但Git-Bash已成功删除rm:

资源管理器删除:"由于文件已打开,无法完成操作."

cmd :: del <path>"访问被拒绝"

PS :: Remove-Item -Force -Path <path>"无法删除项目.拒绝访问路径."

C++ remove():返回-1

C++ unlink():返回-1

C++ _unlink():返回-1

git-bash rm <path>:成功

以上可以在不同文件上重复执行.

还有其他锁定文件,git-bash也rm成功删除(我过去使用过它,最近没有使用过,我没有其他具体的例子).

但它并不总是有效:在测试应用程序中,我使用了打开文本文件fopen(),包括Git-Bash在内的所有方法rm都无法成功删除它.

那么,Git-Bash rm如何运作?

c++ powershell git-bash

8
推荐指数
1
解决办法
1088
查看次数

标签 统计

git ×4

c++ ×1

git-bash ×1

github ×1

powershell ×1