Your changes are not lost.
The first time they were there on the new testbranch
after step 3, it was because the changes weren't committed to branch dev
.
Next, when you committed those to the testbranch
, the commit got associated with testbranch
, and thus won't be available on dev
branch before you explicitly tell git
to do so.
In this case, it seems to me that you are fine with all the code in testbranch
to be brought into dev
branch, so you can do a simple merge
.
git checkout dev
git merge testbranch
This will bring all your changes to dev
branch.