Hg Mercurial Cheat Sheet

Similar documents
Development in code_aster Using Mercurial. Code_Aster, Salome-Meca course material GNU FDL licence (

Lab #2 Physics 91SI Spring 2013

Hg Tutorial. For : COP Object oriented Programming (Using C++) Biswas Parajuli

A Brief Git Primer for CS 350

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Programming with Haiku

Software Development I

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Version Control Systems (VCS)

Working with GIT. Florido Paganelli Lund University MNXB Florido Paganelli MNXB Working with git 1/47

Computer Science Design I Version Control with Git

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Make sure to mark it private. Make sure to make it a Mercurial one and not a Git one.

Version control. what is version control? setting up Git simple command-line usage Git basics

Working in Teams CS 520 Theory and Practice of Software Engineering Fall 2018

Object Oriented Programming. Week 1 Part 2 Git and egit

CS 320 Introduction to Software Engineering Spring February 06, 2017

How to Work with Mercurial

Introduction to Version Control with Git

Git. Presenter: Haotao (Eric) Lai Contact:

Managing Projects with Git

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

Introduction to Version Control

Submitting your Work using GIT

Lecture 01 - Working with Linux Servers and Git

A BASIC UNDERSTANDING OF VERSION CONTROL

Git Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : October, More documents are freely available at PythonDSP

Git Tutorial. Version: 0.2. Anders Nilsson April 1, 2014

Software Revision Control for MASS. Git Installation / Configuration / Use

Using git to download and update BOUT++

Version control CSE 403

Version Control. Version Control

CS 390 Software Engineering Lecture 5 More Git

GUIDE TO MAKE A REAL CONTRIBUTION TO AN OPEN SOURCE PROJECT 1. 1

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Subversion (and Git) Winter 2019

Using Subversion with LeMANS and MONACO

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Branching and Merging

Git: Distributed Version Control

License. Introduction to Version Control with Git. Local Version Control Systems. Why Use Version Control?

USER GUIDE. MADCAP FLARE 2017 r3. Source Control: Git

Introduction to Git and Github

Windows. Everywhere else

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

Revision control. INF5750/ Lecture 2 (Part I)

Version Control. Version Control

CESSDA Expert Seminar 13 & 14 September 2016 Prague, Czech Republic

Review Version Control Concepts

GIT. CS 490MT/5555, Spring 2017, Yongjie Zheng

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

Using Git to Manage Source RTL

SyncHg Documentation. Release Graeme Coupar

Tutorial: Getting Started with Git. Introduction to version control Benefits of using Git Basic commands Workflow

Welcome! Virtual tutorial starts at 15:00 GMT. Please leave feedback afterwards at:

Index. Alias syntax, 31 Author and commit attributes, 334

Version Control. Software Carpentry Github s Hello World Git For Ages 4 And Up You need source code control now

USER GUIDE. MADCAP FLARE 2018 r2. What's New

Lab 1 1 Due Wed., 2 Sept. 2015

Assumptions. GIT Commands. OS Commands

Git: Distributed Version Control

Topics covered. Introduction to Git Git workflows Git key concepts Hands on session Branching models. Git 2

Source Code Management wih git

Version control system (VCS)

MNXB Working with SVN. Florido Paganelli Lund University Tutorial 2b

Version Control System - Git. zswu

Agenda. - Final Project Info. - All things Git. - Make sure to come to lab for Python next week

Version Control with Git ME 461 Fall 2018

Lab 08. Command Line and Git

From Commits to Collaboration: A Git Tutorial for Social Scientists

Version Control: Gitting Started

Introduction to distributed version control with git

GETTING TO KNOW GIT: PART II JUSTIN ELLIOTT PENN STATE UNIVERSITY

Software Revision Control for MASS. Git Basics, Best Practices

CS 261 Recitation 1 Compiling C on UNIX

Intro to Linux & Command Line

About SJTUG. SJTU *nix User Group SJTU Joyful Techie User Group

USING GIT FOR AUTOMATION AND COLLABORATION JUSTIN ELLIOTT - MATT HANSEN PENN STATE UNIVERSITY

SyncHg Documentation. Release Graeme Coupar

Portions adapted from A Visual Guide to Version Control. Introduction to CVS

Overview. 1. Install git and create a Github account 2. What is git? 3. How does git work? 4. What is GitHub? 5. Quick example using git and GitHub

Introduction to Monte Python

Git(Lab) Tutorial and Hands-On

Revision Control and GIT

1. Git. Robert Snapp

git the SCM system Jan-Simon Möller training.linuxfoundation.org

Chapter 5. Version Control: Git

Version Control with GIT

Introduction, Instructions and Conventions

Version Control Systems

Lab Exercise Git: A distributed version control system

Effective Software Development and Version Control

Mid-resolution InfRAreD Astronomical Spectrograph

An Introduction to Subversion

Version control CSE 403

! #Running this command from the top directory of your project will add all your changes."! $ git add."

TangeloHub Documentation

Git Tutorial. André Sailer. ILD Technical Meeting April 24, 2017 CERN-EP-LCD. ILD Technical Meeting, Apr 24, 2017 A. Sailer: Git Tutorial 1/36

CSCI 2132 Software Development. Lecture 5: File Permissions

Git and GitHub. Dan Wysocki. February 12, Dan Wysocki Git and GitHub February 12, / 48

G E T T I N G S TA R T E D W I T H G I T

Transcription:

Hg Mercurial Cheat Sheet Serge Y. Stroobandt Copyright 2013 2016, licensed under Creative Commons BY-NC-SA This page is work in progress! Much of the explanatory text still needs to be written. Nonetheless, the basic outline of this page may already be useful and this is why I am sharing it. In the mean time, please, bare with me and check back for updates. Distributed revision control Why I went with Mercurial Python, Mozilla, Java, Vim Mercurial has been better supported under Windows. Mercurial also offers named branches Emil Sit: August 2008: Mercurial offers a comfortable command-line experience, learning Git can be a bit daunting December 2011: Git has three philosophical distinctions in its favour, as well as more attention to detail Lowest common denominator It is more important that people start using distributed revision control instead of nothing at all. The Pro Git book is available online. Collaboration styles Mercurial working practices Collaborating with other people 1

Use SSH shorthand Installation $ sudo apt-get update $ sudo apt-get install mercurial mercurial-git meld Configuration Local system-wide configuration $ nano.bashrc export NAME="John Doe" export EMAIL="john.doe@domain.url" $ source.bashrc ~/.hgrc on a client user@client $ nano ~/.hgrc [ui] username = user@client editor = nano merge = meld ssh = ssh -C [extensions] convert = graphlog = hggit = /usr/share/pyshared/hgext/git mq = progress = strip = 2

~/.hgrc on the server user@server $ nano ~/.hgrc [ui] username = user@server editor = nano merge = meld ssh = ssh -C [extensions] convert = graphlog = hggit = /usr/share/pyshared/hgext/git mq = progress = strip = [hooks] changegroup = hg update >&2 Initiating One starts with initiate a new repository. $ hg ini directory Status $ hg st Ignoring Ignore files $ nano./.hgignore syntax:glob **.bak **.log **.pdf new/** 3

List ignored files This lists the ignored files without the status prefix: hg st -ni Remove ignored files locally The following command will delete all ignored files in the local folder. Use with caution. hg st -ni0 xargs -0 rm Adding and removing files To schedule all new files to be added to the repository for version control and to record the deletion of all missing files from the repository: $ hg addr The files will be added or removed at the next commit. To undo before that, see hg forget. Committing Forget changes before commit To undo a file add $ hg forget filepath Revert local changes To revert a locally modified file back to the latest local repository version, without creating a backup: $ hg rev -C filepath 4

To do the same for all files in the repository: $ hg rev -C --all Commit changes Some advice: Commit early and commit often! $ hg com -m 'commit message' If the message consists out of a single word, the quotes can be omitted. $ hg com -m one-word-message Change the last commit message $ hg com --amend -m 'new commit message' Undo the last commit This command should be used with care. There is no way to undo a rollback. Moreover, this command is not intended for use on public repositories. Please, consult the help information. Use hg commit --amend instead of rollback to correct mistakes in the last commit. $ hg rollback repository tip rolled back to revision x (undo commit) working directory now based on revision x Above command does not alter the working directory. To entirely clean up the working directory and revert to the previous commit status, use the following commands. $ hg rev -C -a reverting... $ hg st -nu0 xargs -0 rm 5

Wipe files from history Matters are a bit more complicated than represented here, so be sure to first read the following excellent article. This is especially the case when working in a group of collaborators. So here is the short story. First, create a map.txt file: # This filemap is used to exclude specific files exclude subdir/filename1.ext exclude subdir/filename2.ext exclude subdir2 Then, run these commands: hg convert --filemap map.txt ~/oldrepo ~/newrepo cd ~/newrepo hg update Attention: All instances of the old repository, including those on remote clients and servers, need to be removed with rm -R. Then, clone again from the new repository. Pushing Push to the main repository $ nano.hg/hgrc [paths] default = user@server.url:port/relative_path $ hg out $ hg push 6

Auto-update the main repository.hg/hgrc [hooks] changegroup = hg update Push to an additional server.hg/hgrc [paths] webserver = ssh://user@webserver.url/public_html [hooks] changegroup = hg update >&2 changegroup.webserver = hg push -f webserver This goes in.hg/hgrc on the remote repository. The output in this case needs to be redirected to stderr (&2), because stdout (&1) is used for the actual data stream. By the way, stdin is &0. Instead of a web server, a web-based repository hosting service like Bitbucket could be used. The path would then be something along the line of: ssh://hg@bitbucket.org/user_name/repository_name. Cloning Clone from a remote repository Hg Mercurial can be used with the secure shell protocol: $ hg clone ssh://user@server.url:port/relative_remote_path $ hg clone ssh://user@server.url:port//absolute_remote_path Clone to a remote repository $ hg clone localrepo ssh://user@server.url:port/relative_remote_path $ hg clone localrepo ssh://user@server.url:port//absolute_remote_path 7

Pulling Pull updates $ hg inc $ hg pull -u Viewing View repository heads $ hg heads View the log For a semi-graphical log in ASCII art, add the graphlog= extension to the ~/.hgrc configuration file as follows: [extensions] graphlog = To view the graphical log: $ hg log -G TortoiseHg TortoiseHg is an application with a graphical user interface to view and manipulate hg-mercurial repositories. $ sudo apt install tortoisehg 8

Merging ~/.hgrc [ui] merge = meld $ hg merge $ hg com -m merge $ hg push Reverting Revert to a previous version To revert the repository to a previous version, without creating a backup: $ hg rev -C -r revision_number -a Work from there and change something. $ hg com -m reversion $ hg push Branching Create a new branch $ hg branch experiment View the name of the current branch $ hg branch 9

List all branches $ hg branches Change back to the default branch Use the hg update command to switch to an existing branch; for example the default branch. $ hg update default Merge a branch with the default branch By default, push will not permit the creation of new heads at the destination, since multiple heads would make it unclear which head to use. In this situation, it is recommended to pull and merge before pushing. $ hg update default $ hg merge experiment $ hg com -m "branch merge" Close a branch Use hg commit --close-branch to mark the current branch head as closed. When all heads of a branch are closed, the branch will be considered closed. Closing branches prevents the list of branches from growing too large. $ hg update experiment $ hg com --close-branch Push a new branch Use --new-branch to instruct push to create a new named branch that is currently not present at the destination. This allows you to only create a new branch without forcing any other changes. $ hg pus --new-branch 10

Prune a dead branch Here is how to strip a revision and all later revisions on the same branch. Please note, this is a history altering operation. Be careful no one else pulled this repository. Moreover, for this to work, the MqExtension needs to be loaded as mq = in ~/.hgrc. hg strip --no-backup -r revisionnumber Help Here is how to get help with a specific command: $ hg help command $ hg -v help command Use a Git repository Add the following lines to ~/.hgrc : [extensions] hggit = /usr/share/pyshared/hgext/git Resolve local status corruption $ hg update -C $ hg debugrebuildstate 11

This work is licensed under a Creative Commons Attribution NonCommercial ShareAlike 4.0 International License. Other licensing available on request. Unattended CSS typesetting with. This work is published at http://hamwaves.com/hg-mercurial/en/. Last update: Saturday, September 16, 2017. 12