- Building Enterprise JavaScript Applications
- Daniel Li
- 308字
- 2021-07-23 16:31:22
Making work-in-progress (WIP) commits
However, we have already made some changes related to our Create User feature, and we can't check out the dev branch unless we git commit or git stash these changes. Ideally, we should commit the entire Create User feature together; it is not clean to have work-in-progress (WIP) commits in our Git history tree.
To resolve this dilemma, we can use git stash, but it can be quite confusing and you risk losing your work. Instead, we are going to commit the WIP changes now and amend the commit later with the full implementation. We can do this because we are working on our local feature branch, not one of the permanent dev or master branches. This means that as long we do not push our changes onto the remote repository, no one else will know about the WIP commit.
The workflow will be as follows:
- git commit our WIP changes related to our Create User feature on the create-user/main branch.
- git checkout the dev branch.
- Add the @babel/node package once again.
- git commit the VSCode debugger configuration changes onto the dev branch.
- git checkout the create-user/main branch.
- git rebase the create-user/main branch onto the dev branch.
- Continue to work on the feature.
- Run git add and git commit --amend to commit our implementation code in the existing commit.
- Run yarn install to make sure all the packages are linked, especially those that are present in the create-user/main branch but not the dev branch.
Following that workflow, we should execute the following commands:
$ git add package.json yarn.lock spec/cucumber/steps/index.js
$ git commit -m "WIP Implement Create User with Empty Payload"
$ git checkout dev
$ yarn add @babel/node --dev
$ git add -A
$ git commit -m "Add configuration for VSCode Debugger"
$ git checkout create-user/main
$ git rebase dev
$ yarn install