TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Simple git workflow is simple

219 pointsby durdnover 11 years ago

28 comments

tmoertelover 11 years ago
The perennial problem with discussions of Git workflows is the underlying belief that there exists, if only we can find it, the One True Workflow. This belief is false.<p>Git is a powerful, general tool that lends itself to just about any workflow imaginable and, because of its adaptability, different teams will naturally converge on different Git workflows as &quot;right.&quot; These teams, however, have a hard time imagining and thus accounting for the conditions and preferences of other teams, and end up advocating for their workflows as the best workflow.<p>Thus we end up with strongly held and yet contradictory beliefs. Some people claim that &quot;rebasing is a bad habit: it destroys history&quot; while others claim that &quot;rebasing is a good habit: it prevents repo cruft.&quot; Who is right?<p>It depends on your preferences, which ought to reflect your team, your project, and your company culture.<p>For my projects, I prefer to edit my work into tight, clean commits before merging them into the mainline branch. That&#x27;s because I value the <i>logical story</i> of my software&#x27;s evolution and not the <i>physical story</i>. I want my commits to tell the story that Feature X was built from three sequentially self-supporting changes XA, XB, and XC, not that, while developing Feature X, (1) I was sick for two days, (2) Bob committed an important unrelated hotfix to the mainline tree that (3) I had to work around, and (4) Sally had to later revert Bob&#x27;s commit. That I was sick, that Bob commited a hotfix, that I had to work around it, and that Sally rolled it back are all real. They happened. But none of those things are fundamental to the nature of Feature X and how I rendered that nature into code. I consider that stuff noise and make sure it&#x27;s gone before my commits land in production.<p>But that&#x27;s me. Maybe <i>you</i> care about that stuff. If so, your Git workflow and mine are going to be very different.<p>And that&#x27;s okay.
评论 #7040429 未加载
评论 #7038195 未加载
评论 #7045998 未加载
评论 #7038145 未加载
评论 #7041813 未加载
评论 #7039412 未加载
jherikoover 11 years ago
&gt; When development is complete record an explicit merge<p>This is so important I felt it necessary to quote it and restate it as a comment.<p>Not knowing this ahead of time caused me to have a serious problem on ship day that most source control solutions make trivial to fix - it got solved in the end, but that hiccup was unwelcome. The result was that I threw git out as a viable option for source control (until hg screws me I have no reason to switch back beyond its popularity).<p>Bad defaults are bugs imo...<p>EDIT: to be clear i&#x27;m referring to the advice to use --no-ff for a merge. i am of the opinion that --no-ff should be the default, because using it causes no damage, but not using it can cause problems.
评论 #7037204 未加载
评论 #7040118 未加载
aparadjaover 11 years ago
I understand that collaborating on code is a hard problem. But if this is the simplest solution, part of me wants to throw it all in the trash and start over. It&#x27;s just not good enough.
评论 #7037002 未加载
评论 #7037214 未加载
评论 #7043619 未加载
crazygringoover 11 years ago
&gt; <i>4. To keep your feature branch fresh and up to date with the latest changes in master, use rebase</i><p>Could somebody please explain this more? My understanding of rebase which comes from [1] is that it&#x27;s used to bring a feature branch onto a master branch, or similar, and &#x27;erase evidence&#x27; of there ever having been a branch, and squash the intermediate commits on that branch, to make things cleaner.<p>For bringing changes on the master branch into your feature branch, what&#x27;s the benefit of using rebase instead of just normally merging the changes in? I&#x27;m clearly missing something here. They say &#x27;Resolving conflicts during the rebase allows you to have always clean merges at the end of the feature development.&#x27;, but I don&#x27;t see what merge vs rebase has to do with resolving conflicts -- you have to resolve conflicts when you merge master into your feature branch just the same.<p>I can understand using rebasing to keep the master branch&#x27;s history &#x27;clean&#x27;, but what&#x27;s the reason with a feature branch?<p>[1] <a href="http://git-scm.com/book/en/Git-Branching-Rebasing" rel="nofollow">http:&#x2F;&#x2F;git-scm.com&#x2F;book&#x2F;en&#x2F;Git-Branching-Rebasing</a>
评论 #7037848 未加载
评论 #7038225 未加载
评论 #7037869 未加载
thatthatisover 11 years ago
I think <a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="nofollow">http:&#x2F;&#x2F;nvie.com&#x2F;posts&#x2F;a-successful-git-branching-model&#x2F;</a> is simpler and more robust.
评论 #7037811 未加载
评论 #7037680 未加载
评论 #7037400 未加载
评论 #7041083 未加载
评论 #7042730 未加载
sceleratover 11 years ago
One reason I like git-flow is its insistence on two main branches, master and deploy. In a CI environment, it&#x27;s great to have a CI pointing at develop so that &quot;finished&quot; features and merges are constantly being tested, plus, you always have a master branch which (theoretically) is only getting fed from fully-tested release branches. Master stays pristine. Develop <i>should</i> also be pristine but if it fails, it&#x27;s no big deal.<p>Nevertheless, IME finding the right branching&#x2F;release paradigm in group development situations has not been the biggest problem. The bigger hurdle has been reaching basic understanding of git and SCM tools in general -- even among groups of very good&#x2F;experienced programmers.
king_magicover 11 years ago
How is this in any way better or simpler than Git Flow? IMO Git Flow is conceptually easy to understand and easy to implement. Using it on a pretty decent sized team (40+ developers) and it works great for us - and is easy for newcomers to the project to pick up.
评论 #7036972 未加载
trumbitta2over 11 years ago
I, for one, like this workflow which is simple and elicits collaboration and creates history: <a href="http://scottchacon.com/2011/08/31/github-flow.html" rel="nofollow">http:&#x2F;&#x2F;scottchacon.com&#x2F;2011&#x2F;08&#x2F;31&#x2F;github-flow.html</a>
kristofferover 11 years ago
&quot;In the (somewhat less common) case where other people are also working on the same shared remote feature branch, also rebase changes coming from it&quot;<p>I don&#x27;t think this use case is uncommon, and unfortunately when you are multiple persons working on a shared remote feature branch you can&#x27;t rebase the branch from master and then push it either.<p>What work flow do people who have shared remote branches use? Or do you think that way of working is broken?
rsanheimover 11 years ago
This is definitely not simple. So much rebasing. Ugh.
jordanlevover 11 years ago
&gt; 6. Perform a final rebase cleanup after the pull request has been approved<p>I understood everything except this step. Could someone clarify this for me? Especially this part: &quot;In some cases ... you can rebase also during development, but I strongly advise against it.&quot; Isn&#x27;t the entire article about rebasing during development? Why did this become a &quot;in some cases&quot; thing now in step 6, when step 4 (rebasing during development) seems like the critical step in the whole process?<p>Otherwise, this is a great step-by-step (especially seeing the commands that get run for each step -- up until now I only understood the rebase process conceptually, but was always scared to try it due to not knowing the exact commands to run in the exact order, or which branch to run them on). Thanks!
评论 #7038405 未加载
评论 #7038444 未加载
Pxtlover 11 years ago
&quot;simple&quot;<p><a href="http://tartley.com/?p=1267" rel="nofollow">http:&#x2F;&#x2F;tartley.com&#x2F;?p=1267</a>
评论 #7039970 未加载
relediover 11 years ago
I use a similar workflow and documented it: <a href="http://freeseer.github.io/contribute/basics.html#basic-workflow" rel="nofollow">http:&#x2F;&#x2F;freeseer.github.io&#x2F;contribute&#x2F;basics.html#basic-workf...</a><p>One difference is that instead of fetching and rebasing changes from origin straight into your topic branch, we recommend checking out master, pulling in changes, checking out your topic branch and rebasing against master. This way master is also up to date.<p>As for the .gitconfig tip near the end, I don&#x27;t think changing the behaviour of such a common command like pull is a good idea. Better to be explicit.
评论 #7037828 未加载
sergiotapiaover 11 years ago
Just use Gitflow peeps. It&#x27;s simple, not mentally taxing, and having a feature branch for each feature (JIRA ticket, or whatever unit you&#x27;re using) makes things very atomic and simple.
评论 #7038294 未加载
评论 #7037634 未加载
评论 #7037636 未加载
lmmover 11 years ago
Rebase is a bad habit to get into (because it means other people can&#x27;t pull your branches), and a pain to fix when it conflicts. Merge master into your working branch instead.
评论 #7037098 未加载
评论 #7037386 未加载
评论 #7037597 未加载
评论 #7037723 未加载
aidenn0over 11 years ago
&gt;A manual on workflows does not come pre-installed with git, but maybe it should seeing how many people have questions on the topic.<p><pre><code> git help workflows</code></pre>
badman_tingover 11 years ago
If it works for you then great, but it&#x27;s kind of crazy to me that anyone would call this &quot;simple&quot;. That strikes me as disingenuous, to say the least.
thyrsusover 11 years ago
My biggest workflow problem is remembering to commit. Then it occurs to me to commit, I do a &quot;git status&quot; and holy crud, what do all those changes do?<p>So I&#x27;m resolving now to commit... when?<p>Any time a new test succeeds (without breaking old tests)<p>-or-<p>Any time I run a test<p>-or-<p>Something else I haven&#x27;t thought of?<p>It needs to be something more concrete than &quot;when you&#x27;ve done something significant&quot;. The mental energy drain of deciding &quot;significant&quot; is a killer.<p>Help?
评论 #7038489 未加载
评论 #7040199 未加载
codereflectionover 11 years ago
This is exactly the workflow I have been using for a couple of years now. I&#x27;m not sure that labeling it &quot;simple&quot; is accurate, but it is generally easier to understand than some other workflows I&#x27;ve seen.
trustfundbabyover 11 years ago
In the (somewhat less common) case where other people are also working on the same shared remote feature branch, also rebase changes coming from it:<p>git rebase origin&#x2F;PRJ-123-awesome-feature<p>At this point solve any conflicts that come out of the rebase.<p>----------------------<p>I don&#x27;t know about this, we&#x27;ve used this before and what winds up happening is a lot of<p><pre><code> git push --force </code></pre> since the the remote feature branch&#x27;s history is always being rewritten and won&#x27;t match the local histories. We only rebase if the feature branch is being worked on by a single developer. And a bunch of other grief ... or am I missing something?
评论 #7037984 未加载
skuunk1over 11 years ago
Interestingly enough, I was just documenting my team&#x27;s workflow in my blog...<p><a href="http://www.skuunk.com/2014/01/our-git-workflow.html" rel="nofollow">http:&#x2F;&#x2F;www.skuunk.com&#x2F;2014&#x2F;01&#x2F;our-git-workflow.html</a><p>Very similar to this, but we add a couple of steps to allow a business owner to examine a feature before it gets accepted and also we use an integration branch to deal with merge conflicts before creating a releasable master branch.
bashcoderover 11 years ago
The main problem I have with this workflow is step 6, after a pull request has been approved:<p>&gt; (At this point if you have rewritten the history of a published branch and provided that no one else will commit to it or use it, you might need to push your changes using the –force flag).<p>I don&#x27;t think it&#x27;s a great idea to institutionalize what most would agree is a Bad Git Practice, especially in a multi-user environment.
neurostimulantover 11 years ago
The blog is down at the moment (returning http 503).<p>Here is the cached version: <a href="http://webcache.googleusercontent.com/search?q=cache:https://blogs.atlassian.com/2014/01/simple-git-workflow-simple/" rel="nofollow">http:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:https:&#x2F;...</a>
peterattover 11 years ago
Maybe a stupid question, but I am not clear on what happens if, in between you send a pull request and the code is merged with master, the master branch itself gets modified. In that case you couldn&#x27;t rebase and you could have merge conflicts with master, or am I missing something?
steveklabnikover 11 years ago
git actually does come with a manpage on workflows: <a href="https://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;pub&#x2F;software&#x2F;scm&#x2F;git&#x2F;docs&#x2F;gitworkflow...</a>
pmoriciover 11 years ago
Typical. They can&#x27;t even keep their own website up. I had to use some of there tools in a job I had once and they were not reliable at all.
pyrrhotechover 11 years ago
I really love the design and color scheme of the Atlassian website.
VladRussian2over 11 years ago
this post could have been titled &quot;git workflow replicating workflow in centralized VCS (like CVS, Perforce, etc..)&quot;