0

My short question is - is there a possibility to add description (message) to staged files? Some alternative like "git commit -m "Fancy message goes here"".

Thanks.

Oleg Novosad
  • 2,261
  • 1
  • 27
  • 28
  • No. Why would you want to do that, anyway? Staging is only an intermediate step towards committing, which is when you convey meaning (via the commit message). Surely. when you're preparing your next commit, you know *why* you're staging some files and not others, no? – jub0bs Jun 25 '15 at 08:47
  • I wanted it because of pre-commit reviews so my "staging message" will be populated to review. – Oleg Novosad Jun 25 '15 at 08:49
  • What do you mean by "pre-commit reviews"? Do you mean that you need other people's approval before you make a commit? (If so, that's mad!) – jub0bs Jun 25 '15 at 08:50
  • That's the process in a big team actually. And I want to make it clear so other developers can make appropriate changes after review, update staged files, and then create final commit. – Oleg Novosad Jun 25 '15 at 08:52
  • 1
    Most seasoned Git users would agree, I believe, that this is a terrible workflow. A commit, not the staging of files, represents a unit of work. A commit is the business of *one* developer, not an entire team. Commits, not staged files, should be reviewed. You're free to reorganise work further down the road (by merging branches, etc.), but what you're suggesting is bonkers. – jub0bs Jun 25 '15 at 08:54
  • Ok, thank you for your responses. – Oleg Novosad Jun 25 '15 at 09:02
  • To echo what Jubobs said, I would recommend having developers commit their proposed changes to a new branch, and have them make the appropriate changes after code review in that branch as well, then merge into the main branch when all is well. If you do not want the "pre review" code in the history, you can always flatten the commits as well. – David Deutsch Jun 25 '15 at 11:39
  • Thanks. We are currently working on the best approach around this. Probably we'll come with different branch + staged changes added in review and one final commit after review is done. – Oleg Novosad Jun 25 '15 at 11:50

1 Answers1

1

Staged files are purely local to your repo and not available for review (because nobody else would have access to your local repo)

Commits, on the other hand, can be pushed and reviewed.
Typically on a Gerrit server, which will allow reviews and votes, and will either reject those commits, and push them in turn to the target repo, in a "guarded commits" way.

https://review.typo3.org/Documentation/images/intro-quick-central-gerrit.png

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Staged files also can be added to review. When you used "git add" command they are stated as "changed" and using some tool like SmartBear you can add "changed" files to review. – Oleg Novosad Jun 25 '15 at 11:49
  • @Array SmartBear runs on your machine where you have your local repo? Or do you do a `ccollab addgitdiffs` (http://support.smartbear.com/viewarticle/20580/)? – VonC Jun 25 '15 at 11:50
  • 1
    @Array In any case, it doesn't make sense. You review commits, nothing else. – VonC Jun 25 '15 at 11:52