News for hackers. Stuff that matters.
Re:High-Level Problems with Git and How to Fix Them by yeukhon on Tuesday December 12, 2017 @03:13AM (#15903841)
Here are the commands I use:

git init

git clone

git checkout

git commit

git commit -m

git commit —amend

git rebase

git add/rm/diff [—cached]

git push

git branch

and a few more I can’t remember exactly.

I try to keep my git workflow simple. The most complex is probably checkout abd rebase with several different branches.

Re:High-Level Problems with Git and How to Fix Them by emj on Tuesday December 12, 2017 @04:16AM (#15904095)
You are already using ammend and rebase, you can do plenty of complex and hairy stuff with that, especially as a team. I'm also guessing you use merge and log at times. FWIW this is my philosphy with git too, but have you not experienced the points he brings up? I was nodding my head at all of them; branches are time-consuming, staging is problematic and forks are a bad analogy.

The recent post and hype about the Facebook, Google and Microsoft monorepos should make us ask the question what our systems for source control is supposed to do really.

  save changes to a source code
  save changes to big binary assets
  annotate those changes
  annotate the files themselves
  tagging versions 
  signing of code
  code review
  handle regressions testing
  collaborating (ACL, DCVS, official monkey patching etc)
  merging
  search on the whole code base
  refactoring on large code bases
All these things have uses but they are not really supposed to be tied to one VCS, we have very basic needs when working with source code streamlining the UX for that workflow might be more important and in the same time opening up for easy access to the other stuff.
Re:High-Level Problems with Git and How to Fix Them by cryptonector on Tuesday December 12, 2017 @05:55PM (#15910255)
I especially use:

- git add -e

- git rebase -i --autostash <upstream>

- git checkout -f -- <file> (to undo changes)

- git diff/log (of course)

- git reset HEAD^ (to undo the head commit but leave its changes extant in the workspace so I can then git add -e and commit them in logical units)

Re:High-Level Problems with Git and How to Fix Them by saltedmd5 on Tuesday December 12, 2017 @04:28AM (#15904150)
"I try to keep my git workflow simple," and yet I see 'git rebase' but no 'git merge' in that list.
Re:High-Level Problems with Git and How to Fix Them by zegl on Tuesday December 12, 2017 @05:19AM (#15904368)
`rebase` is simpler than `merge` in larger teams/projects, as the history will be much cleaner.
Re:High-Level Problems with Git and How to Fix Them by rbehrends on Tuesday December 12, 2017 @01:17PM (#15907966)
History is only "cleaner" because Git in its default configuration only throws the raw version graph at you and fails to visualize it in a readable fashion. With a properly structured visualization, such as Bazaar's hierarchical logs, merging is not just as clean, it actually carries more information.

In hierarchical logs, a merge commit stands for the series of commits that are being merged. You can then unfold such commits and view the series of commits as a nested list of commits (which may again contain merge commits).

Think of a merge commit as the equivalent of a procedure call where the procedure body is the series of commits being merged.

(Note that there are other ways to visualize version graphs with merge commits; this is just the simplest way to do it and could actually be easily added on top of Git.)

Rebasing has two problems. It discards the original version structure and it can create commits that never build or don't pass tests (because they never existed as such).

Frequent use of rebasing is almost always an indication that a VCS is lacking important functionality.

Re:High-Level Problems with Git and How to Fix Them by kazinator on Tuesday December 12, 2017 @01:38PM (#15908174)
> it actually carries more information

None of that information is too relevant. If you have the commits individually cherry picked in your stream, that's most of the info you ever need about those commits. There is some earlier version of those commits in a different stream, where they look different. Usually, who cares.

The way to track that is some sort of additional meta-data. An example of this is the Gerrit Change-ID.

Re:High-Level Problems with Git and How to Fix Them by saltedmd5 on Tuesday December 12, 2017 @06:20AM (#15904688)
Rebase is not simpler in any context - rebase rewrites history, which, if branches have been pushed to remotes, then necessitates force pushes, which in turn breaks any other instances of the same branch. By using rebase to "keep history clean" you are largely undermining git's power as a DVCS.

Rebase as a tool is not inherently bad but it is definitely not simpler than merge - it introduces additional considerations, requires a deeper understanding of git for effective use and is a dangerous tool in the hands of people who do not understand what it is doing and in my experience most teams that are using it as a core part of their workflow are doing so for the wrong reasons (generally because of a fundamental misunderstanding of how branching and merging works in git and why it works that way).

Re:High-Level Problems with Git and How to Fix Them by kazinator on Tuesday December 12, 2017 @01:44PM (#15908219)
That is not correct; rebase per se doesn't rewrite history.

Rebase is basically just cherry picks. You can rewind a branch and then cherry-pick, so that the picks are non-fastforward. That's rewriting history. Cherry picking without rolling back is fastforward, and so doesn't rewrite history.

The Gerrit review system on top of Git is based on cherry-picking; it doesn't rewrite history.

If some developers are collaborating on a feature which is on a branch, they could agree from time to time to rebase that branch to a newer mainline.

Whether or not that is done by a history rewrite simply hinges on whether the same branch name is used for the rebased branch or not. The rebase is what it is: if you plant that rewrite as the original branch name, then you have a non-fastforward change. If a new branch name is made, then it isn't a rewrite.

Merging a feature branch onto a trunk can always be done in a fastforward way using rebase/cherry-pick.

Rebasing is provably simpler than merge. Merge depends on complications in the git object representation which could be removed while rebase remains what it is. If you only ever rebase, you never see a commit with multiple parents; the feature is superfluous and turns git histories into hairballs.

Re:High-Level Problems with Git and How to Fix Them by saltedmd5 on Tuesday December 12, 2017 @03:43PM (#15909281)
AFAIK rebase always rewrites history. If you rebase your feature branch, you have at least rewritten the history of the local branch even if you then delete it and push to a new remote branch. The trunk will subsequently get a FF merge.

Rebase might give you a "simpler" end result in terms of what the history looks like but conceptually it is much less simple in terms of its mechanism and its implications (e.g. rebasing a branch with multiple contributors screws up the audit trail as it now looks like they made their changes at a different time and in a different context to when they actually did) than the idea of a graph with two branches and a merge commit.

I have seen teams with limited git experience switch from habitually rebasing public branches to accepting merge commits and suddenly cure a whole host of workflow problems.

If you can rebase directly onto a fresh branch (not something I've seen) then I am fairly sure that that's not part of your average workflow - establishing new branches every time you want to update from trunk comes with its own communication overhead too.

Re:High-Level Problems with Git and How to Fix Them by yeukhon on Tuesday December 12, 2017 @12:29PM (#15907457)
Simple or not, it's a subjective. As you said it:

> > it introduces additional considerations, requires a deeper understanding of git for effective use and is a dangerous tool in the hands of people who do not understand what it is doing

I am taught git with rebase (though merge when I use hg) so I am already too used to it. Branching then rebase is not that difficult if you keep your workflow consistent and quick iteration. You should be up to date whenever possible. Amending and rewriting history/comment also requires using rebase.

YMMV.

Re:High-Level Problems with Git and How to Fix Them by muxator on Tuesday December 12, 2017 @08:47AM (#15905509)
mercurial has "phases", which means that it allows free rebasibg and history rewriting for changes that are still not public.

As soon as a tree is pushes, those changes become public, and you need to explicitly force the history rewriting operations.

This is part of the " safe defaults" approach of mercurial.

Re:High-Level Problems with Git and How to Fix Them by majewsky on Tuesday December 12, 2017 @04:29AM (#15904160)
> I try to keep my git workflow simple.

> git rebase

Yeah... :)

Re:High-Level Problems with Git and How to Fix Them by tarnacious_ on Tuesday December 12, 2017 @11:11AM (#15906636)
I often rebase my local commits on a remote branch to keep my branch up to date with changes in the remote branch.

I find this simpler and cleaner than introducing a series of merge commits in my local branch.

Re:High-Level Problems with Git and How to Fix Them by kazinator on Tuesday December 12, 2017 @11:51AM (#15907050)
A merge should always be done by rebasing the to-be-merged material onto the target-of-merge branch. This way not only is the history linear (and thus understandable, rather than some indecipherable "git log --graph" ball of yarn) but the individual changes are properly re-worked to fit into the target.

When we go back and view those changes, they are all in terms of this codebase, not the original changes that do not apply cleanly to this codebase. That's a big problem with git merges: the merge itself is one huge jump that collapses all the changes. The original changes are traceable in its lineage through the second parent, but those are the verbatim original changes, not the merged changes.

Re:High-Level Problems with Git and How to Fix Them by kazinator on Tuesday December 12, 2017 @11:23AM (#15906765)
I believe a fork of git should be made which entirely eliminates the concept of multiple parents from the representation of a commit. In the same breath, it would drop support for git merge and git log --graph.