Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Git's typical workflow compare to Mercurial's?

Tags:

git

workflow

On hginit.com, a typical hg workflow is described as:

1.If you haven’t done so in a while, get the latest version that everyone else is working off of:
hg pull
hg up
2.Make some changes
3.Commit them (locally)
4.Repeat steps 2-3 until you’ve got some nice code that you’re willing to
inflict on everyone else
5.When you’re ready to share:
hg pull to get everyone else’s changes (if there are any)
hg merge to merge them into yours
test! to make sure the merge didn’t screw anything up
hg commit (the merge) hg push

I use hg pretty regularly, and this all makes sense to me. I've just started using git, and I haven't found anything that describes a typical workflow like the above quote. I was hoping someone could explain the difference in workflow between these two tools and describe a typical workflow in git.

like image 333
user Avatar asked Jan 11 '11 17:01

user


People also ask

What is the difference between Git and Mercurial?

Mercurial Is Safer For Less Experienced Users By default, Mercurial doesn't allow you to change history. However, Git allows all involved developers to change the version history. Obviously, this can have disastrous consequences. With basic Mercurial, you can only change your last commit with “hg commit – amend”.

Does anyone use Mercurial?

According to Chan, less than 1 per cent of new Bitbucket users choose Mercurial as their version control system. And she cites data from StackOverflow's 2018 Developer Survey that's no less damning: 87 per cent of developers use Git and only about 4 per cent user Mercurial.

Can you use Mercurial with github?

The answer is: yes, it can! You will be able to do that by using the Mercurial bookmark, which are the Mercurial counterpart of Git branches and are used as such by the hggit plugin.


1 Answers

It's about the same:

  1. git pull # Get latest code
  2. Make some changes
  3. git add foo/*.rb # Add files to commit
  4. git commit -m "Made it more betta" # Make and describe the commit
  5. git push # Push the changes to some master repo
    • The push will fail if you're behind the master, in which case you must:
      1. git pull # Automatically merge what it can, and show conflicts
      2. Manually fix any conflicts
      3. git add . # Add whatever was conflicting
      4. git commit -m "Merging with master"
      5. git push

As with Mercurial you can repeat steps 2-4 as much as you like; you don't have to push after every commit.

like image 172
Phrogz Avatar answered Sep 20 '22 02:09

Phrogz