我想获取远程git仓库的最后提交ID。
命令git rev-parse HEAD
适用于本地克隆的git repo,但是我想通过CURL命令从原始GIT repo中获取它。
例如:我想获取git URL的最后提交ID [https://git.appfactorypreview.wso2.com/history/apiapp.git/。]
怎么样?
我开始收到此消息。 无论我编辑什么并尝试提交,它都说没有什么要提交。 看起来git看不到我的工作目录,而看不到其他地方。
如果我运行git status
,则输出相同:
nothing to commit (working directory clean)
如果我创建新分支并编辑某些内容,则会发生相同的情况。 当我需要修复合并冲突时,这开始发生。 当我想将一个分支与master分支合并时,我必须手动对其进行修复,并且我的文件必须看起来像该分支中的一样,覆盖了master分支中的相同文件。 因此,我添加了这些文件,并使其合并。 但是,无论我进行什么更改,它都显示没有要提交的内容。
在这里可以做什么?
是否可以修改默认git commit消息的注释部分?我想为我的用户添加更多的“上下文”信息。
# Please enter the commit message for your changes.
# (Comment lines starting with '#' will not be included)
# Explicit paths specified without -i nor -o; assuming --only paths...
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: test.txt
#
这个问题已经在这里有了答案:
我已经提交了abc
,我想列出为该提交修改过的文件。
git命令是什么,它将列出该提交的已修改文件?
这个问题已经在这里有了答案:
我很惊讶,在SO上找不到答案。
我们可以在git中恢复/恢复已删除的提交吗?
例如,这就是我所做的:
# Remove the last commit from my local branch
$ git reset --hard HEAD~1
# Force push the delete
$ git push --force
现在,是否有办法找回已删除的提交? git是否在内部记录(记录)删除?
我需要一些帮助。 可能只显示一个提交ID? 由于git log -3显示1-3的日志,所以我只想显示3。什么可能的命令会匹配呢?
我使用命令
git log -3 --pretty=format:"%h"
结果是
ffbef87
cf0e073
1c76c5d
我只想显示1c76c5d。
我有一个从GitHub分叉的存储库,对该存储库进行了一些修改。 但是,在某个提交中,更改了一些我要提交请求请求的文件,而其他修改后的文件不在请求中。
拉请求是否合并所有提交,还是需要做一些特殊的事情来隔离此提交?
我想找出我在以下提交中添加了以下代码:
if (getListView().getChildCount() == 0)
getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
我该如何实现?
如何从Git存储库中删除已删除的文件?
我已经删除了JavaScript库的文件夹,其中包含许多文件。 然后,我去提交更改,如下所示:
git add .
git commit "message"
git status
但是它将所有这些文件显示为“已删除....”。
我怎样才能使它们消失?
在我的本地仓库中,我有一次提交带有错误的提交消息。
我已经用git commit --amend
发布了错误的提交消息。
现在,远程仓库(由GitHub托管)也具有错误的提交消息。
我已经尝试了git commit --amend
,但是发现在这种情况下它对我不起作用,因为自错误的提交以来,我还进行了其他提交。
您将如何解决这种情况?
我似乎不能只提交文件中的更改的一部分,似乎全部是文件,或者什么也不提交,我在Intellij中使用Git,可以吗?
谢谢。
➜〜myproject git:(master)reword
commit a99cce8240495de29254b5df8745e41815db5a75
Author: My Name <my@mail.com>
Date: Thu Aug 16 00:59:05 2012 +0200
.gitignore edits
commit 5bccda674c7ca51e849741290530a0d48efd69e8
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:36:39 2012 +0200
Create .gitignore file
commit 6707a66191c84ec6fbf148f8f1c3e8ac83453ae3
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:13:05 2012 +0200
Initial commit (with a misleading message)
reword
我的第一次提交的提交消息(6707a66)➜〜myproject git:(master)reword
(...进入vim)
pick 5bccda6 Create .gitignore file
pick a99cce8 .gitignore edits
# Rebase 6707a66..a99cce8 onto 6707a66
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
在这种情况下,我想更正相关问题(在git parlance中为reword
):
初始提交(带有误导性消息)
......适当的事情。
毫不奇怪,我的上述尝试没有成功,因为第一次提交显然没有任何父提交。 (当您rebase
时,您需要在reword
之前引用下一个最早的提交,对吗?)
因此,我的问题的要点是,您可以通过其他任何方式实现这一目标吗?
有什么区别:
git commit -a
git commit -a
我应该做两件事,还是多余的?
在我读过的所有Git教程中,他们都说你可以这样做:
git init
git add .
git commit
当我这样做时,我打开了一个大文本文件。 这些教程似乎都没有解决这个问题,所以我不知道该怎么处理该文件或者如果有的话要放入什么内容。
我已提交更改,忘记将文件添加到更改集。 在其他提交之后,我意识到该文件现在从HEAD^4
提交中丢失。
如何重写先前的提交以包含丢失的文件?
我尝试通过运行以下命令从远程仓库中删除文件:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD
但是Git抱怨说
无法创建新备份。 refs / original /中已存在先前的备份
使用-f强制覆盖备份
rm:无法删除/.git-rewrite/backup-refs:权限被拒绝
rm:无法删除目录/.git-rewrite:目录不为空
这是在我已经删除了Windows上的.git-rewrite目录之后。
我该如何删除该文件? 这是一个29Mb的文件,坐在我的仓库,所以我非常需要删除该文件。
我试图删除git rebase -i
中的提交,但显然是因为提交触及了很多不同的文件,Git抱怨冲突,我流产是为了安全。
我正在努力恢复我的工作。 我愚蠢地做了git reset --hard
,但在此之前我只做了get add .
而没做git commit
.请帮忙! 这是我的日志:
MacBookPro:api user$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
# modified: .gitignore
...
MacBookPro:api user$ git reset --hard
HEAD is now at ff546fa added new strucuture for api
在这种情况下可以撤消git reset --hard
吗?
我有一个需要在存储库中引用初始提交的脚本。 git有特殊参考号HEAD
,但没有相应的TAIL
.我在git help rev-parse
中找不到任何能够帮助我的内容。
这是我想做的事情:
git show TAIL
这是我的一个选择:
git show `git log --reverse | if read a commit ; then echo $commit ; fi`
这非常hacky,取决于git log的输出没有改变。
现在我只标记初始提交并将其用作我的refspec。 但是,我想发布一个通用工具,因此这不是一个很好的选择。
我很好奇如何删除git中的第一个提交。
在做出任何事情之前的修改是什么? 此修订版是否有名称或标记?