Github workflow for single developer
Asked Answered
L

1

15

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
Lew answered 29/7, 2012 at 11:26 Comment(0)
H
5

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

Hinkel answered 29/7, 2012 at 12:42 Comment(3)
Thanks - it's good to know I'm on the right track! I'm still a little confused by branches though and I think that's where my merging headache comes from. When I create a new branch in Github for Windows, should I expect that it would create a new directory somewhere? Because if it doesn't then aren't I just editing the code that is in my master branch?Lew
Git stores everything in a bunch of deltas in the .git folder. So when you make a new branch, it's like you're working on a copy of your master/cloned branch. But it's all in the same folder (commit some changes and flip branches and reopen your file to see). Keep an eye on what branch you have checked out, because it can be easy to start writing a bunch of stuff, forgetting you didn't switch branches and you end up committing to master instead of your feature branch. That's where stashes come in very handy.Sleeping
Apologies for not accepting this as the answer to my question sooner, some how I seem to have missed your last comment which answered all of my questions. Thanks very much!Lew

© 2022 - 2024 — McMap. All rights reserved.