Frequently Asked Questions about git

Fixing mistakes

When I "git push", I get this error message

If the error message has a URL in it, just follow it. The list of those errors is enumerated at Git/Help.

How do I throw away local changes (like svn revert)?


First, you have to unstage changes (ie, undoing git add <file>):

git reset HEAD <file>

You can alias this to git unstage if you like:

git config --global alias.unstage 'reset HEAD'

Then, completely throw away the unstaged changes:

git checkout -- <file>

This can also be done in a single step:

git checkout HEAD <file>

To throw away all changes in the tree, from the top-level directory (eg, equivalent to svn revert -R .):

git reset --hard HEAD

Beware though! "git reset --hard" is a VERY sharp tool. It's impossible to undo its damage, if it causes any.

How do I undo an '''unpushed''' commit (like if it had never happened)?

For the last n commits, do:

git reset HEAD~n

So if you only want to revert the last commit, do:

git reset HEAD~1

How do I undo a '''pushed''' commit (like if it had never happened)?

Note: This section is outdated as GNOME moved from to See

So if you only want to revert the last commit, do:

git reset HEAD^ --hard
git push origin -f

How do I remove a remote branch/tag I accidently created?

You can simply do:

git push origin :branchname

or for a tag:

git push origin :tagname


git push --exec=force origin :tagname

Trying to delete a branch or tag I get "error: refname 'something' is ambiguous"

This means you are trying to delete a branch (or a tag) when there is both a branch and a tag with that name.

You probably tried to delete the branch or tag with:

git push origin :something

To disambiguate the tag or branch, you needs to pass in the full ref. For branches:

git push origin :heads/something

and for tags:

git push origin :tags/something


How do I add a description to the git web view? What is this "blah.doap"?

DOAP files are a standard way to describe free software projects. Every repository should have a reponame.doap file in the repository's toplevel directory.

For example, if your project is called gnome-foo, create a gnome-foo.doap file in its toplevel directory. You can steal this template:

<Project xmlns:rdf=""

  <name xml:lang="en">repository-name</name>
  <shortdesc xml:lang="en">My awesome project</shortdesc>
  <description>GNOME Shell provides core user interface functions for the GNOME 3
desktop, like switching to windows and launching applications.
GNOME Shell takes advantage of the capabilities of modern graphics
hardware and introduces innovative user interface concepts to
provide a visually attractive and easy to use experience.

Tarball releases are provided largely for distributions to build
packages. If you are interested in building GNOME Shell from source,
we would recommend building from version control using the build
script described at:

Not only will that give you the very latest version of this rapidly
changing project, it will be much easier than get GNOME Shell and
its dependencies to build from tarballs.</description>
  <homepage rdf:resource="" />
  <mailing-list rdf:resource="" />
  <download-page rdf:resource="" />
  <bug-database rdf:resource="" />
  <category rdf:resource="" />

      <foaf:name>Rupert the Monkey</foaf:name>

      <foaf:name>Ruperts Brother</foaf:name>

The fragment portion of the category field's rdf:resource can be one of admin, bindings, deprecated, desktop, development, infrastructure, platform, or productivity. If your project does not belong in one of these categories, leave the category element out, and your repository will appear under the "Other" heading in cgit.

You can see the DOAP web page for more information, or original announcement about using DOAP for Gnome.

How do I get a plain text file of all GNOME repositories?

Use the file We use this e.g. to keep the commits-list topics up to date.

How do I determine who pushed a certain commit?

git log --format=full

To always show the full log:

git config --global format.pretty full

Or use a link like, e.g. for gnome-terminal module.

I'm doing my first code contribution to GNOME, when I "git push", I get "fatal: the remote end hung up unexpectedly"

To push patches direct to a code repository you must have commit access and a Git account. If you don't have a Git account (and thus not commit access) ask the maintainer in same Bugzilla report where you sent the patch to commit the patch for you, if the maintainer have not done so.

How do I convert an anonymous clone to a non-anonymous (eponymous) clone?

The easiest way in converting an anonymous clone to a clone with your account credentials is to

git config remote.origin.url ssh://

How do I create a personal WIP branch?

Note: This section is outdated as GNOME moved from to See has a convention allowing personal WIP branches to be created, following the naming scheme:


where $username is your nickname or username, and $branch_name is the descriptive name of the branch.

Any branch prefixed with ‘wip/’ allows force-pushes, so you may rewrite history on a WIP branch as much as you like.

The intention for allowing these branches is to standardise how people create personal branches of others’ modules. Note that you do not need the module maintainer’s permission to create such a branch — branches are cheap. Please delete personal branches once they are obsoleted or merged, however.

Personal WIP branches are effectively equivalent to forking a project on the GNOME github mirror and pushing a branch there. This is an equally acceptable way of prototyping a feature, and does not require maintainer approval, though most maintainers require patches to be submitted via Bugzilla (using git-bz) rather than a github pull request.

Similarly, maintainers may create project-wide WIP branches following the scheme:


These do require maintainer approval to push, but since they are WIP branches, also allow force-pushes.

Git/FAQ (last edited 2018-12-14 12:28:37 by AndreKlapper)