Does Git allow me to write my next commit message during development?

I am new to Git. Is it possible to create a commit message step by step during development? Because I am very tired of having to revisit all the changes during a commit, or to commit frequently. Sorry if I ask questions here :)

+1


source to share


3 answers


Just test the changes as you make them, don't wait until you have a lot of changes. Not only will it make your commit messages more manageable, but it will help you have better control over your work, allow you to track changes more narrowly, undo them if necessary, etc. Etc.



+6


source


Nickstar 's answer and ventsyv 's answer sound. Read them and collect them. However, if you really insist, you can prepare the next commit message in a text file before starting git commit

.

  • Create a file named nextcommitmessage.txt

    ; save it in your favorite text editor and prepare a message for your next commit in it when you make changes to your working tree.
  • Configure everything that needs to be done in the next commit (be careful, don't put nextcommitmessage.txt

    it though!).
  • Make sure you are happy with the content before proceeding nextcommitmessage.txt

    .
  • When you are ready to commit, run

    git commit -F path/to/nextcommitmessage.txt
    
          

    or alternatively

    git commit --file=path/to/nextcommitmessage.txt
    
          

    This will cause Git to use the content nextcommitmessage.txt

    as the message for that commit, instead of opening your main editor and prompting you to write a commit message from scratch.




Alternatively, you can start with a series of small commits and then crush them with just one commit (assuming you didn't push them). When you do squash, Git will open up your editor and prompt you to merge the messages of the individual commits into one.

+5


source


The idea behind git is to commit shortly and commit often. So whenever you add your commit message to your question, just pass the partial message instead, which you add to your big message. There is no need to nudge every commit. This can and should be postponed until you commit to your current workflow.

+2


source







All Articles