I’m new to git and testing it out right now. On my local machine I do frequent commits. At intervals I want to push the code to a central repo. At this moment I publish all commits done. When I work alone this is not a big issue, but when I work with multiple dev’s on a project this gets chaotic. Meanwhile I would like to have all local commits preserved on my local machine, just in case.
Is this a good way to work with git? Is this possible? Or am I thinking the wrong way?
One way you could deal with this is to make yourself a personal development branch in your local repository. It’s just a regular branch, nothing special, but commits on the branch will not get pushed to the central repository when you run
git push. When you’re ready to share your changes, merge the commits from your personal branch into the master branch and then you can push them to the central repository.A variation on this would be to start a new branch for each logical feature you work on, so that you would have many small personal development branches instead of one big one. Then you can delete the feature branches once you merge them into the master branch.