In this article, we will see the best way to mark a git commit as work in progress.
When we are working on some feature in a large project, it is common to make several commits that are not to be merged with the main code base. In such cases, it is required to mark the commit as a work in progress.
To mark git commit as work in progress :
1. First, we need to stage the changes that we want to commit.
Before, we mark the commit as work in progress, first we need to stage the changes that we want to commit. Use the following command.
git add <file>
The above command stages the changes of the specified file. We can use git add . command to stage all changes made in the working directory.
2. Now, we need to create the “work in progress commit“.
Once we have staged the changes, we can create a work in progress commit using the following command.
git commit -m "WIP: Work in progress"
Using the -m
we can add a message to the commit. In this case, the commit message is “WIP: Work in progress,” which indicates that the commit is not complete.
3. After creating the work in progress commit, we can continue working on the changes.
Once we have the additional changes and staged them, we can update the work in progress commit using the following command.
git commit --amend -m "WIP: Work in progress"
The --amend
flag allows us to modify the previous commit. In this case, we are modifying the work in progress commit to include the additional changes.
4. Finalize the changes : Once we have completed all the changes and are ready to merge into the codebase, we can finalize the changes by removing the “WIP” tag from the commit message.
git commit --amend -m "Final commit message"
Replace the “Final commit message” with the commit message that describes the changes that we are going to commit.