Skip to end of metadata
Go to start of metadata

Prerequisites: having Git installed. For installation and configuration instruction, please refer to Installing Git.

Overview and online documentation

http://rogerdudler.github.com/git-guide/ The simple guide

http://progit.org/ Excellent book by the GitHub founder with free online HTML / PDF / ePub / mobi versions.

http://git-scm.com/documentation

http://gitready.com/

Git commands

Most useful commands

To clone a repository, do:

To retrieve remote changes, do:

To update your repository according to remote changes, do:

This is equivalent to:

To view the current status of your repository, do:

To commit local changes to a file, do:

or, if you'd like to handle all modified files at once:

To push those changes remotely, do:

To view the changeset of a given commit, do:

To apply a given changeset to another branch, do:

To fix mistakes in the last commit it is possible to use `git commit --amend`. Suppose you made a mistake and made a commit with a bad content, and you forgot to reference the JIRA issue in the message:

To fix it just edit the file to replace the faulty line:

and then redo the commit with the right commit message:

To undo the last commit (without having pushed anything to public repo), do:

To merge a branch, read the documentation at http://progit.org/book/ch3-2.html or wait for someone to explain it here

To revert some changes, read the documentation at http://progit.org/2011/07/11/reset.html or wait for someone to explain it here

Merging a pull request

First if the pull request is perfectly ok (reference a Jira issue if changes are not trivial, properly formatted, ...) and the contributor has signed the contributor agreement (if required), just merge it using the GitHub interface. Else, ask the user to make the required changes first, commenting inside the commits or the whole pull request or the Jira issue.

If you'd like to merge the pull request, but add some changes to it, here are the steps you can follow. Let's assume that the user name is "contributor" and he's issuing a pull request from the branch NXP-1234 in his own repo https://github.com/contributor/nuxeo-core.git to branch master in http://github.com/nuxeo/nuxeo-core.git.

Go back to the pull request in the GithHub UI and refresh the page: it' should have been closed by GitHub. Don't forget to add a comment to thank the contributor!

Command mappings for a Mercurial user

Here are simple commands and correspondences between Mercurial (we were used to) and Git:

See Git Hg rosetta stone and Cheat sheets

Show file content in a given revision <=> hg cat
Apply the changes introduced by some existing commits <=> hg transplant
Undo last commit (without having pushed anything to public repo) <=> hg rollback

Nuxeo common usage and best practices

gitf equivalent function to hgf is available at root of Nuxeo in scripts/gitfunctions.sh.

Strictly follow Nuxeo naming policy for branches and tags : create dedicated branches named "fix-NXP-1234-somethingWrong" or "feature-NXP-1234-someNewFeature" while working. When your work is achieved, merge the branch and delete it.

Always reference JIRA issues in the commits' comments.

Use the same name for a local branch than its corresponding remote branch.

Advanced usage and specific use cases

Some useful commands.

Add a remote repository to a local Git repository
Push to master branch on remote repository with alias origin
Rename a branch
Remove a branch
Remove old (stale) remote branch references
Create an annotated tag
Remove a tag
Push a tag
Remove a remote tag

Converting a Mercurial repository to a Git repository

Here is an example using hg-fast-export with Nuxeo DAM mercurial repository:

Migrate from Mercurial to Git

More info here

Cleanup post migration

Notes/tips:

  • "default" Mercurial branch will be mapped to "master" Git branch. If you were not using the "default" branch but for instance "5.5", do:
  • Move .hgignore to .gitignore
  • Add remote repository; push branches and tags
  • Set the Mercurial repository as deprecated.
  • Activate GitHub hooks after having pushed the migration.
Related pages
Page: Installing Git (Core Developer Guide)
Page: Getting the Nuxeo source code (Core Developer Guide)
Page: Git usage (Core Developer Guide)
Labels:
git git Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jan 31, 2012

    behind an enterprise proxy which doesn't allow the git protocol you have to use the http protocol and pass your proxy configuration to git

    e.g : 

    1. git config --global http.proxy http://user:password@proxyHost:proxyPort
    2. git clone http://github.com/nuxeo/nuxeo.git