when I was working on projects that uses the control system git, each time I want to commit then push my modifs I have ofcourse to git pull
before. But the problems that I meet is that in many times git prohibits me to pull because I should before commit my local changes. What I used to do is that I have an other clean git repo where I don't modify it directly, but when I need I use it to git pull
then merge my modifs to it using meld, from the other repo where I work. But I think that this way is not the best and lose a lot of time, it's time to optimize it. What I'm thinking to do is that I create an other local branch "work_branch" and commit my modifs to it locally then merge commits from "work_branch" to "master" then push in master after the pull. So the scenario should be like that:
git branch work_branch
git checkout work_branch
#modify in branch work_branch
git commit
git add <files list>
git commit -m "fixes branch work" #local commit
gitk ==> get the id of "fixes branch work" commit (example: 5b099287c229e16c24bfcdbfd6fba384cfe165e6)
git checkout master
git pull
git cherry-pick 5b099287c229e16c24bfcdbfd6fba384cfe165e6 #merge "fixes branch work" commit from work_branch to master branch
git push
The problem that I met is after the third step (#modify in branch work_branch), each modif in the branch work_branch is viewed by the master branch, but what I want is that master branch can see from work_branch only the merged commit after git cherry-pick
command.
Is there a way to improve my solution. Or is there an other good way to optimize working with git.