DEV Community

paschdan
paschdan

Posted on

splitting a commit with npm changes - introduction

Introduction

In this series i will cover the techniques how to split a commit into multiple commits, while also maintaining npm packages in the commits.

I will show the technique for multiple git clients.

The first part of the series is the introduction, where we introduce the code, we are working with.

get to know the code

for learning how to split, we have the following demo repository:

https://github.com/paschdan/git-split-demo

the project is a demo repository, where a pull request is stated, that installs the following packages:

  • eslint - for linting our future javascript code
  • eslint configuration for standardjs
  • babel - to compile our source code

additionally a first hello world module was added.

unfortunately all this happened in one commit, and the maintainer of the repository would like the author of the PR to split his commit into multiple parts.

Our Task and the Goal of this Series is: split the PR into the requested commits.

prerequisites

to run the demo, you will at least need git and node12+

try out the demo

To get started, we want to clone the demo repository and check out the pull request branch:

git clone https://github.com/paschdan/git-split-demo.git

next we want to switch to the branch of the PR, we want to edit:

git checkout add-npm-packages-in-one-commit

now we can install our npm dependencies to test the demo:

npm install

after the dependencies are installed, we can test our script:

npm test

this prints Hello World to the console, because we overrided the npm test command with node lib/index.js

In the next chapter we will start to split this commit into multiple, with the command line git cli, so stay tuned.

Top comments (0)