Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github workflow for single developer

I would like some feedback on my git workflow because this is my first use of it and despite reading various articles and Stack Overflow questions, I'm not sure that my process is correct. This is my current workflow (note that I am using the Github for Windows application for all of my git interactions):

  1. Decide what the next feature is that I'm going to implement.
  2. Create a branch with a suitably descriptive name for the feature. I do this by clicking on the branch button in Github for Windows and typing a new name.
  3. Write some code.
  4. Commit those changes to my new branch.
  5. Write some more code.
  6. Commit those changes to my new branch.
  7. I've finished implementing the feature so I want to merge my changes back to the master branch. So I click on the 'manage' button underneath the branch heading.
  8. Merge the new branch into the master branch.
  9. Delete the new branch.

I am quite happy with the process up until step 7 at which point I am a little confused. I think my confusion lies in the fact that I'm trying to use the Github for Windows application rather than using the command line. The application does seem to make things easier but there is a bit of a disconnect in my understanding between some of the commands/instructions I see mentioned and the actions you would take in the application.

Let me ask some specific questions:

  1. Is my workflow actually correct? If not, what is wrong with it and how can I improve it?
  2. Should I be "publishing" my changes to the new branch? My understanding is that this is the equivalent of doing git push at the command line. Is that true? If so I think I would only want to do that when I am either finished implementing the feature or it is in a decent state?
  3. Should I be deleting the branch when I have merged it into the master branch or should it be left around forever?
  4. Do I need to publish the master branch when I have completed the merge or is this implicit?
  5. I am sometimes unable to perform the merge and get this error message:

    Unable to merge

    Failed to merge 'test' into 'master'. You might need to open a shell and debug the state of this repo.

When this occurred before, I was able to change to the master branch and merge the new branch into the master branch however that no longer works. No matter which branch I am in, I cannot merge the two branches. Both are in sync and I've published all the changes from my test branch. What should I be typing in the shell to find out why I can't merge the branches?

For reference, these are the main links that have prompted my process:

  1. Scott Chacon on the workflow at Gitub
  2. Git workflow for a single developer on a local repository
  3. Git workflow for a single user
like image 663
Stuart Leyland-Cole Avatar asked Jul 29 '12 11:07

Stuart Leyland-Cole


Video Answer


1 Answers

What you are describing sounds like a common branching workflow that works very well even for multiple developers on the same code base. It's pretty much completely covered by git flow which is a extension of git command line to automate certain steps. It's worth checking out.

I'm not a big fan of UI tools for git. I'm using the command line most of the time. So I'm not experienced with GitHub for Windows. But I bet your problems occur because of your merges are no fast-forwards anymore. This would require a manual merge step that is (afaik) not covered by the tool.

There is no strong reason to keep branches around after merging them into your upstream. But one is to track what commits went into a certain feature. I would suggest to publish the branches if you decide to keep them. You are not dependent on the code lying around on you local machine. To keep the branches doesn't make your repository much bigger by the way but pollutes the sight. Most of the time the commits are present anyway in your upstream branch.

You will have to publish (push) your master branch after merging in.

To get familiar with the git command line tool I suggest starting with the Introduction to Git and GitHub from the GitHub guys and follow their link references for more details.

Hope that helps

like image 97
iltempo Avatar answered Oct 16 '22 16:10

iltempo