My question could go into the basics of git but I have some misunderstanding and I wanted to have advice from the most experienced developers of git.
My scenario is as follows:
For some projet, I have two branch preprod
and master
preprod
: this branch is used to receive local developments from all developers, once the client validates these developments, I merge this preprod
branch into master
master
: is for the production environment.
Scenario :
I created a new branch to develop auto-login
feature,
git checkout preprod
git pull
git checkout -b auto_login_v1
I developped this feature, I commited (2 files), pushed then I merged auto_login_v1
branch into preprod
. *Until here everything is good.
Now I create a new branch for another feature newsletter
,
git checkout preprod
git pull
git checkout -b newsletter_v1
And like the first step, I commited (1 file), pushed then I merged newsletter_v1
branch into preprod
.
Now my client told me to deploy the newsletter feature in the production environment, so I merged newsletter_v1
branch into master
.
The problem with that is by merging just the 2nd branch newsletter_v1
which contains (1 file basically), unintentionally, I also merged the (2 files) of the first branch auto_login_v1
while I just wanted the second branch newsletter_v1
with (1 file).
Why I got this (deployed 3 files instead of 1) ? because I merged the first branch in preprod
then I pulled it ?
2) What is the recommended good practice in the case where we just want to merge one feature (branch) without another ?