Git is a distributed revision control system, and the system currently used by Amarok (since switching from SVN in 2010). Thanks to Ian for the initial git information and for being the resident Git expert.
User Config (IMPORTANT!!!)
If you plan on ever pushing a commit to main repository, be sure to set your name and e-mail for commit messages:
git config --global user.name "John Doe" git config --global user.email "[email protected]"
The above two commands will set your name and e-mail in Git (globally). This will allow Git to automatically tag all of your commits with your name and e-mail address.
To view the revision history and the source tree, go to https://invent.kde.org/kde/amarok. To checkout a copy of the most current source tree, run:
git clone https://invent.kde.org/kde/amarok.git cd amarok git remote set-url --push origin [email protected]:kde/amarok.git
This will create a local copy of the repository under the directory amarok/ in the directory in which the command was executed. The repo will be set to pull from the fast git:// URL and push commits using SSH.
All information on this page is merely an introduction to Git. For more complete information, see
You can also ask the developers on #amarok if you need more help.
Updating Your Repository
To update your local clone of the Amarok repository, please execute
git pull --rebase
This command will run git fetch to download all new commits in the remote branch, and git rebase to add them to your local clone, "replaying" any changes you may have made locally on top of the commits pulled in. To save your time typing --rebase every time when pulling from master, issue
git config branch.master.rebase true
To see all of the commits in your current branch, run
For a graphical view of the revision history, you can run
This program should have been installed with Git, and provides a nice graphical view of the revision history.
git status # A summary of which files are changed/new/deleted/etc. git diff # Show the actual changes
git commit -a # Commit all current changes
After the last command, Git will open a text editor to allow you to add the commit message. Please write a concise, yet descriptive, summary of the changes included in the commit, then save the file and exit. The option "-a" tells Git to include all changes made to already-existing files. This includes modifications and file deletes. It does not, however, encompass new files. To tell Git to include new files, you have to explicitly run
git add /path/to/new/file1 /path/to/new/file2 ...
before running git commit. To commit only changes made to certain files, you can similarly run git add with the paths of the files whose changes you do want to commit. You can also try either of the following for a more interactive method of adding changes:
git add --interactive git add --path # Essentially the same, but jumps directly to the patch subcommand
If you have access to the Amarok repository, you can then run
to push your local changes to the remote Amarok repository, but always check that you're going to push right things before with gitk or a similar tool.
One of Git's greatest strengths lies in branching. If are planning to make complicated changes to the source code, you can easily create a private branch, track your changes in the branch, and get the changes working before committing the whole thing to the main Amarok Git repository.
Creating a New Branch
By default, your local clone of the Amarok repository lies in the "master" branch. To create a private branch from this one:
git branch NewBranchName # Create the new branch, with name "NewBranchName" git checkout NewBranchName # Switch to the new branch git checkout master # Switch back to the master branch
To see a list of all of your branches:
The branch with an asterisk before it is the one you are currently working in.
Merging a Branch into master
Merging your branch to master is easy, following commands will merge a branch into master, keeping its history, making sure the merge commit is created and embedding a list of commits into the merge commit text:
git checkout master git merge --no-ff --log MYBRANCH
After you've merged the changes from a branch into the master, you can delete the branch:
git branch -d MYBRANCH
Maintaining a Long-lived Branch
This section deals with some recommended techniques when dealing with long-lived feature branches, perhaps entire GSoC projects.
Be sure not to get unlucky by choosing an unstable/buggy commit as you're branching point, because you'll may be using that for months. Test that features you'll be affecting work as expected.
Backup & Publish Code Using a Personal Clone
To backup your work and make it accessible for interested parties, you are encouraged to create a personal Amarok repo clone on git.kde.org. Then add it as another remote to your Amarok repository
git remote add personal [email protected]:clones/amarok/<your identity.kde.org login>/<clone name, perhaps just amarok>
and push your feature branch to it (use the -u option first time so that git remembers branch upstream)
git checkout gsoc # assuming your feature branch is called gsoc git push -u personal gsoc
Don't Merge from master to a Feature Branch
Merging from master into a feature branch creates a messy "loopy" history, which is generally frowned upon, because it's a structure without semantics. Rebasing a long-lived feature branch
git rebase master gsoc
should be preferred to merging upstream master repeatedly into it, on the other hand rebasing a published branch will create pain for those who have pulled it.
Unless you depend on some new features being added to upstream master (like API changes, or bugfixes), you don't need to rebase often, or even at all.
Get your code reviewed
Especially in case of GSoC, we recommend to submit weekly diffs to reviewboard (assign to whole amarok team) so that everyone is up-to-date with current advances. Thanks to rbtools, git tags and aliases this can be easy. With following alias in your [amarok repo]/.git/config
[alias] gsoc-review = !post-review --summary '<NAME> GSoC week <NUMBER> (squashed commits, recent on top)' --guess-description --username=<your username> --branch gsoc --parent=gsoc-review-base --open --target-groups=amarok
it is easy as maintaining git tag gsoc-review-base pointed to latest revision you've submitted and issuing
every week or so. These review requests are not meant to be merged (make it clear) and they can be closed as discarded after some time, provided that you've resolved any possible issues spotted by other developers.
...is covered by Merging a Branch into master above, just keep in mind that it is usual to submit a final review request with all the changes and to retain development history as mentioned above. The merge commit is also a place to add any missing BUG:, FIXED-IN: etc. tags and ChangeLog entries if it wasn't already done during feature branch development.
Work through conflicted files by opening them in your mergetool (opendiff, kdiff3, etc.) and choosing left/right chunks. The merged result is staged for commit.
For binary files or if mergetool won't do, resolve the conflict(s) manually and then do:
git add <file1> [<file2> ...]
Once all conflicts are resolved and staged, commit the pending merge with:
Tricks 'n Tips
Oh Shit: Undo
You've made some changes to a file(s) and you've decided you want to scrap all the work.
git checkout /path/to/file
Abandon everything since your last commit. This command can be DANGEROUS. If merging has resulted in conflicts and you'd like to just forget about the merge use this command.
git reset --hard
Undo your most recent successful merge and any changes that occurred after. Useful for forgetting about the merge you just did. If there are conflicts (the merge was not successful), use "git reset --hard" (above) instead.
git reset --hard ORIG_HEAD
Undo your last commit
git reset --soft HEAD^
There are certain folders/files which may not require tracking, and git will say on every checkout and status what these files are, which can be a nuisance. See
Treat yourself to some color. Add the following to ~/.gitconfig
[color] ui = auto [color "diff"] whitespace = red reverse