1

The most common way to accidentally pick up submodule changes is to do a pull, forget to submodule update, and then do a git commit -a (which will add the submodule changes). Is there a way to configure Git so that it ignore submodule changes unless I specifically request it? Is there some other way to molly guard the situation?

2
  • 3
    Not that I'm aware of, but I would question why you're so eager to use git commit -a ... I would definitely hand pick your changes to stage, then check your staged files before committing. Commented Mar 22, 2019 at 21:57
  • For complicated changes I make use of the index, but if I just pulled updates and edited a single file, -a saves me a little time and has very few ways to go wrong... unless there was a submodule update. I'm not alone in this... Commented Mar 24, 2019 at 2:43

1 Answer 1

1

Have you tried an alias? Something as simple as alias gca="git submodule update; git commit -a" would work.

Alternatively, you can look into the wonderful world of Git Hooks.

Neither of these solutions are typically shareable, however. For a shareable solution, you will need to look into a solution like husky from the Node.js world.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.