Don’t Commit Specific Line in GIT

Asked

Viewed 66 times

2

Hello,

Is it possible in Git to ignore a specific line within a file? It would be interesting for cases where we need to register a password, in this case I need to commit the file, but I would like to ignore the line that contains the password.

  • Yes, it’s possible. Most tools allow you to decide which lines will be part of each commit. You commit only the changes you want and the remaining lines are pending.

1 answer

1

When adding the specific file to staging (that is, the space of files that will enter the next commit), add it with:

git add -p <arquivo>

This way you can select the contiguous spaces of modifications in the file.

  • I still can’t find in the documentation how to select parts of the file. Have some example?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.