Git:使用消息推送到远程存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10521628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:39:39  来源:igfitidea点击:

Git: Push to a remote repository with a message

gitmessage

提问by PruitIgoe

My company is incorporating iRise for prototyping and it lacks any kind of versioning (unless making copies of your files with different file names = versioning). Anyway, we're using Git for our version control and since the typical iRise user here will be a graphic/web designer I want to automate the process as much as possible. I have a hot folder running an AppleScript that will push to a remote repository but I'm not sure how to add a message...

我的公司正在整合 iRise 进行原型设计,它缺乏任何类型的版本控制(除非使用不同的文件名复制您的文件 = 版本控制)。无论如何,我们使用 Git 进行版本控制,因为这里的典型 iRise 用户将是图形/网页设计师,我想尽可能地自动化该过程。我有一个运行 AppleScript 的热文件夹,它将推送到远程存储库,但我不确定如何添加消息...

git push TestProject master 

tried

试过了

git push TestProject master -m 'message'

but threw a switch error and showed a list of options, -m not being one of them...

但是抛出了一个开关错误并显示了一个选项列表,-m 不是其中之一...

is this possible or do you have to commit locally first and then push that to the remote and the message will be attached with it?

这是可能的还是您必须先在本地提交然后将其推送到远程并且消息将附加到它?

回答by manojlds

You will have to do a commit ( after adding files)

你将不得不做一个提交(添加文件后)

git commit -m 'message'

and then push:

然后推:

git push TestProject master

You cannot associate a message to the push.

您不能将消息与推送相关联。

回答by Sundar

I think the question is legitimate, and is not completely answered by the answer above. Here is a workflow we use at our company (we use git flow):

我认为这个问题是合理的,上面的答案并没有完全回答。这是我们在公司使用的工作流程(我们使用 git flow):

  1. git flow feature start myFeature
  2. git commit -m 'commit for feature myFeature prior to code review'
  3. initiate code collaborator review with the commit above.
  4. git commit -m 'commit for code review comments/changes for myFeature round1'
  5. <same as above, maybe round2>
  6. git flow feature finish myFeature
    • this merges to local develop branch, and deletes myFeature branch
  7. git push origin develop
  1. git flow 功能启动 myFeature
  2. git commit -m '在代码之前提交功能 myFeature'
  3. 使用上面的提交启动代码协作者。
  4. git commit -m 'commit for code review comments/changes for myFeature round1'
  5. <同上,可能是round2>
  6. git flow 功能完成 myFeature
    • 这合并到本地开发分支,并删除 myFeature 分支
  7. git push origin 开发

Now it would be real nice if we could add a message like this during the push Step 7. like this:

现在,如果我们可以在推送步骤 7 期间添加这样的消息,那就太好了。像这样:

git push -m 'Feature is code complete, code collaborator review ids 1234, 1235.' origin develop

Definitely, not a trivial case where someone is trying to push without commits, but a very useful step where you are annotating a specific push with metadata that provides some audit trail.

当然,这不是有人试图在没有提交的情况下推送的微不足道的情况,而是一个非常有用的步骤,您可以使用提供一些审计跟踪的元数据来注释特定的推送。