例如:我想在这里获得最后提交日期 - https://github.com/elasticsearch/elasticsearch/tree/master/dev-tools/pmd
有了这个,我可以进入 pmd 文件夹 - https://api.github.com/repos/elasticsearch/elasticsearch/contents/dev-tools/pmd
但这没有关于日期的任何数据。我试过了https://api.github.com/repos/elasticsearch/elasticsearch/contents/dev-tools/pmd/commits,这会返回“未找到”消息。
使用 sha 尝试了 git url -https://api.github.com/repos/elasticsearch/elasticsearch/git/blobs/58788337ae94dbeaac72a0901d778a629460c992但即使这样也不会返回任何有用的信息。
如何使用github-api获取文件夹内的提交日期?
我写了一些使用 git 应用补丁的说明。这些说明旨在放入控制台并完成。像这样:
git am bar.patch
git am foo.patch
Run Code Online (Sandbox Code Playgroud)
但是 git 现在要求用户名/电子邮件:
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'root@user-VirtualBox.(none)')
You need to set your committer info first
Run Code Online (Sandbox Code Playgroud)
这似乎不是必需的,因为只有补丁的作者出现在 git 日志中,而不是应用补丁的人。有没有办法忽略配置?
编辑:错别字
为了清理我们的代码,我们想使用 astyle。问题是我们希望有人来完成这项工作,但责怪以前的提交者(代码的真正作者,而不是清理的人)。
有没有办法在 git 中安全地做到这一点?
我很困惑地看到我的同事 Alice 在 git 日志中进行了合并提交,Bob 向我保证确实是他进行了合并。我没有看到鲍勃的其他合并提交,所以看起来爱丽丝以某种方式设法接管了鲍勃的提交。
Alice 确实也提交了一些东西,但她的提交活动很可能是在 Bob 之后的。Alice 仅通过 Visual Studio 的 git ui 使用 git。
我知道可以通过变基操作重写本地提交,但据我了解,通常不会对已推送的提交执行此操作。我认为图形化的 git ui 不会做任何不寻常的事情。
那么为什么我在 git 日志中看到 Alice 是作者和提交者呢?可能发生了什么原因导致这种情况?
编辑:其他提交有明智的作者,所以这不仅仅是配置了错误的用户名。
我当前的默认git日志行运行如下:
git log --graph --date=relative --pretty=format:'%Cblue%h%Creset %Cgreen(%cr)%Creset -%C(yellow)%d%Creset %s' --abbrev-commit -7
Run Code Online (Sandbox Code Playgroud)
然而,有时候,我更喜欢绝对的日期/时间格式,而不是相对格式,所以我尝试了:--date=default而--date=local不是--date=relative甚至--date=..完全省略:结果没有改变.可能它与"log.date配置变量设置log命令的--date选项的默认值有关." , 我不知道.可能我需要重新启动终端(但如果是这种情况我会有点失望......).
简而言之,我想"切换"日期,甚至可以在一个git log实例中使用这两种日期格式.
[
{
"url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"commit": {
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"author": {
"name": "Monalisa Octocat",
"email": "support@github.com",
"date": "2011-04-14T16:00:49Z"
},
"committer": {
"name": "Monalisa Octocat",
"email": "support@github.com",
"date": "2011-04-14T16:00:49Z"
},
"message": "Fix all the bugs",
"tree": {
"url": "https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
}
},
"author": {
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}, …Run Code Online (Sandbox Code Playgroud) 我正在做一个自由职业项目。客户(让我们称他为foobar)要求我使用他的 github 帐户(我的工作 PC 运行 64 位 Windows 10,我安装了 git 2.15.0)上传代码。
所以我做了这些步骤。
转到凭据管理器 -> Windows 凭据 -> 通用凭据。删除了我的 Github 帐户
在源代码目录上,执行标准程序:
git init
git add *
git commit -m "first message"
git remote add origin https://github.com/foobar/supersecretproject.git
git push -u origin master
Run Code Online (Sandbox Code Playgroud)出现了一个 Github 凭据对话框。输入了他的证件。
稍等片刻,是的,代码已提交到 Github。打开 Github 页面,奇怪的是提交者是我,而不是foobar。奇怪的。如何解决这个问题?我想以foobar 的身份提交。