The Add Interactive Command

Learn how to achieve more granular control over having staged changes and unstaged changes.

The git add -i command

Let’s demonstrate how you might want to use this with a simple example:

1	mkdir lgthw_add_i
2	cd lgthw_add_i
3	git init
4	echo 'This is file1' > file1
5	echo 'This is file2' > file2
6	git add file1 file2
7	git commit -am 'files added'
8	cat > file1 << END
9	> Good change
10	> This is file1
11	> Experimental change
12	> END
13	cat > file2 << END
14	> All good
15	> This is file2
16	> END