I am not sure if i use Git correctly so i would like to know what you think about my way and how to make it better.
I`m programming a website were i want to include new features. But for these features i don´t need the complete rest of the website. So what i do is this:
- on branch "master" i create a branch called "justBasics" were i deleted everything that is unnecessary (which is nearly everything).
- on branch "justBasics" i create my feature Branch "feature1". In "feature1" i can, for example, create a new file where i write my feature in.
- Now i want to include feature1 to the master. The bad thing is that the branch "feature1" also includes stuff that i just need to try out my feature and doesn´t belong to the master so cant merge it to master (Or can i use merge? I don´t know how.). For example some code for testing the feature or especially the stuff that i deleted to create "justBasics".
- To include the feature i go back to "master" and create the branch "includeFeature1". In "includeFeature1" i get only the important commits of the feature by cherry-pick.
- now i can merge "includeFeature1" to master
This is how my repository would look at the end:
* c9 (master) merging branch "includeFeature1"
|\
* | c8 some work on master to make this look better
| * c7 (includeFeature1)cherry picking commit c3 and c5
|/
* c6 some work on master to make this look better
| * c5 (feature1) finished feature1
| * c4 some code that is necessary to test feature1. I don´t want this code at the end in my website.
| * c3 started feature1. add a file to work in
| * c2 (JustBasics) i deleted folders, features, preparing main.html to show nothing.
|/
* c1 website til this point. that includes other features
This way works for me but i get some problems with cherry-pick: Somehow when i want to checkout some other branch some old Hunks reappear. Especially when i am on master and i try to checkout "JustBasics", the Hunks from c2 were i deleted all the folders and features reappear and i can´t switch branches. So i have to delete them before i can continue.
How do you work on complete new features were the rest of your code would disturb you?
What do you think about my way?