wiki:UsingGit

Version 32 (modified by Peter Bennett, 8 years ago) (diff)

--

Using git with MythTV

To work with MythTV source code, you may either create a read-only repository (allowing you to build MythTV and make local changes, only):

git clone git://github.com/MythTV/mythtv.git

Or you may create a github account and fork the repository into your account, allowing you to push your changes to your fork (for others to see/use) and to provide pull requests in tickets to get your changes incorporated:

git clone git@github.com:MythTV/mythtv.git

If you are a MythTV developer with commit access, you should use the following repository:

git clone git@code.mythtv.org:mythtv

To switch to another branch:

git checkout fixes/0.27

configuring git

If this is the only git repo you are using:

git config --global user.name "Your Name"
git config --global user.email you@example.com

If you do already have other repos going, you will be better off using (from the mythtv checked-out directory):

cd /path/to/mythtv-git/
git config user.name "Your Name"
git config user.email you@example.com

Please use your real name and a real email address. If you are on the MythTV development team, please use the assigned canonical @mythtv.org email address. This will be attached to each commit you make, and is needed for legality reasons (i.e. to clearly denote the contributors, which can be a life-saver if we have licensing issues later)

The default git push behaviour is inconvenient or dangerous. Without options it will push all matching branches (branches with the same name in the remote and local repository). As above, use --global or run the commands in each repository's checked out directory if you use git for more than just MythTV.

git config --global --add push.default nothing

The first prevents any unwanted changes.

git config --global --add push.default tracking

This configures git to push only the current branch to it's remote tracking branch. That's useful if local branches don't have exactly the same name as the remote branch. mythtv-rec vs. dkristjansson/mythtv-rec for example.

git push -n should always verified before real pushing.

git for svn users

https://git.wiki.kernel.org/index.php/GitSvnCrashCourse

https://git.wiki.kernel.org/images-git/7/78/Git-svn-cheatsheet.pdf

http://git.or.cz/course/svn.html

svn command git command comments
svn checkout git clone
svn diff git diff HEAD pretty much identical
svn diff git diff show differences since last stage commit
svn stat git status
svn commit git commit / git push in git, git commit commits locally, git push pushes to the upstream repo. Additionally, changes must be staged before committing.
---- git add -i / git add -p stage commits
svn update git pull technically, this is two steps combined (git fetch, git merge) git pull --rebase does a rebase instead of a merge
svn update (to recover a single file) git checkout HEAD filename
svn update (to recover all deleted files) git ls-files -d | xargs git checkout --
svn copy (to create a branch) git branch (or git checkout -b)
svn copy (to create a tag) git tag -a
svn switch git checkout branch
svn merge git merge
svn revert git checkout or git reset specify a filename or a directory path for recursive updates
svn revert -R (for pristine index and working copy) git reset --hard applies to entire tree so no filename or directory allowed

Useful git commands

To cherry pick a commit from master to fixes/0.27 (this automatically commits to your local branch):

git checkout fixes/0.27; git cherry-pick -x {commitref} (retrieve commitref hash from git log, e-mail or github history)

Options to use for cherry-pick

  • -s to signoff another person's fix with your name
  • -x append a comment line that says "(cherry picked from commit ...)"
  • -e to edit comment to add ticket number (e.g. Fixes #12345, see below)
  • -n to leave out commit so you can combine multiple cherry-picks into 1 commit.

To see log for specific branch

git log {branchname}

To produce a diff of last two commits in a branch

git diff HEAD~2..

To produce a diff of all changes done on top of origin/HEAD

git diff origin/master..HEAD

To credit a commit to the original author use:

git commit --author "Full Name <email@address>" -s

When committing a change that closes a ticket, add this to the commit comment, to automatically close the ticket:

Fixes #123456

Also, github has a wealth of good information.

MythTV Git Repositories

Name mirrored on GitHub
buildbot-configno
extrasyes
mythtvyes
mythwebyes
nuvexportyes
packagingyes

In addition there are multiple repositories for contributors at https://github.com/MythTV-Clients and https://github.com/MythTV-Themes, see http://mythtv-themes.github.io/