Top github Questions

List of Tags
Matthew Rankin

I created a bugfix branch to fix a bug on a project that I had forked on GitHub. I issued a pull request to the developer to incorporate my fix, but the developer decided to implement a different fix for the problem. At this point, I want to delete the bugfix branch both locally and on my project fork on GitHub.

Successfully Deleted Local Branch

$ git branch -D bugfix
Deleted branch bugfix (was 2a14ef7).

Attempts to Delete Remote Branch

$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.
$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.
$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).
$ git push
Everything up-to-date
$ git pull
 * [new branch]         bugfix  -> origin/bugfix
Already up-to-date.

What do I need to do differently to successfully delete the remotes/origin/bugfix branch both locally and on GitHub?

Answered By: Matthew Rankin ( 1682)

Updated Answer on 1-Feb-12

As of Git v1.7.0, you can delete a remote branch using

git push origin --delete <branchName>

which is easier to remember than

git push origin :<branchName>

which was added in Git v1.5.0 "to delete a remote branch or a tag."

Therefore, the version of Git you have installed will dictate whether you need to use the easier or harder syntax.

Original Answer from 5-Jan-10

From Chapter 3 of Pro Git by Scott Chacon:

Deleting Remote Branches

Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s master branch (or whatever branch your stable codeline is in). You can delete a remote branch using the rather obtuse syntax git push [remotename] :[branch]. If you want to delete your serverfix branch from the server, you run the following:

$ git push origin :serverfix
 - [deleted]         serverfix

Boom. No more branch on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] syntax that we went over a bit earlier. If you leave off the [localbranch] portion, then you’re basically saying, “Take nothing on my side and make it be [remotebranch].”

I issued git push origin :bugfix and it worked beautifully. Scott Chacon was right—I will want to dog ear that page (or virtually dog ear by answering this on StackOverflow).

Crazy Serb

If I do "git log" and get the following output:

[root@me dev]# git log
commit a867b4af366350be2e7c21b8de9cc6504678a61b`
Author: Me 
Date:   Thu Nov 4 18:59:41 2010 -0400

blah blah blah...

commit 25eee4caef46ae64aa08e8ab3f988bc917ee1ce4
Author: Me 
Date:   Thu Nov 4 05:13:39 2010 -0400

more blah blah blah...

commit 0766c053c0ea2035e90f504928f8df3c9363b8bd
Author: Me 
Date:   Thu Nov 4 00:55:06 2010 -0400

And yet more blah blah...

commit 0d1d7fc32e5a947fbd92ee598033d85bfc445a50
Author: Me 
Date:   Wed Nov 3 23:56:08 2010 -0400

Yep, more blah blah.

How do I revert from my current state to the commit made on Nov 3rd, for example?

Answered By: Jefromi ( 663)

This depends a lot on what you mean by "revert".

If you want to temporarily go back to it, fool around, then come back to where you are, all you have to do is check out the desired commit:

# this will detach your HEAD, i.e. leave you with no branch checked out.
git checkout 0d1d7fc32

or if you want to make commits while you're there, go ahead and make a new branch while you're at it:

git checkout -b old-state 0d1d7fc32

If, on the other hand, you want to really get rid of everything you've done since then, there are two possibilities. One, if you haven't published any of these commits, simply reset:

# This will destroy any local modifications
# Don't do it if you have uncommitted work you want to keep
git reset --hard 0d1d7fc32

# Alternatively, if there's work to keep:
git stash
git reset --hard 0d1d7fc32
git stash pop
# This saves the modifications, then reapplies that patch after resetting.
# You could get merge conflicts, if you've modified things which were
# changed since the commit you reset to

On the other hand, if you've published the work, you probably don't want to reset the branch, since that's effectively rewriting history. In that case, you could indeed revert the commits. With git, revert has a very specific meaning: create a commit with the reverse patch to cancel it out. This way you don't rewrite any history.

# This will create three separate revert commits
git revert 0766c053 25eee4ca a867b4af

# To get just one, you could use `rebase -i` to squash them afterwards
# Or, you could do it manually (be sure to do this at top level of the repo)
# get your index and work tree into the desired state, without changing HEAD:
git checkout 0d1d7fc32 .
# and then commit
git commit    # be sure and write a good message describing what you just did

The git-revert manpage actually covers a lot of this in its description. Another useful link from the Git Community Book discussing git-revert is here.


I "accidentally" pushed a commit to github.

Is it possible to remove this commit?

I want to revert my github repository as it was before this commit.

Answered By: Can Berk G&#252;der ( 251)

First, remove the commit on your local repository. You can do this using git rebase -i. For example, if it's your last commit, you can do git rebase -i HEAD~2 and delete the second line within the editor window that pops up.

Then, force push to github by using git push origin +master.

See for more information (i.e. if you want to remove older commits).

Oh, and if your working tree is dirty, you have to do a git stash first, and then a git stash apply after.

Mika Tuupola

Is it somehow possible to automatically have a link to GitHub issue number in the git commit message?

Answered By: NARKOZ ( 237)

With new GitHub issues 2.0 [1] [2] you can use these synonyms to reference an issue and close it:

  • fixes #xxx
  • fixed #xxx
  • close #xxx
  • closes #xxx
  • closed #xxx

Use just #xxx to reference an issue without closing it.

Is there a way in Git to rollback to a much earlier version of a file? I can roll back to the previous version with REVERT, but what if i want to go back to earlier versions? Whats the best workflow for managing waypoints in yout code? Branch each time so that you have a full copy of your code at a certain period in time?

Answered By: Chris Lloyd ( 229)

You can quickly review the changes made to a file using the diff command:

git diff <commit hash> <filename>

Then to revert a specific file to that commit use the reset command:

git reset <commit hash> <filename>

You may need to use the --hard option if you have local modifications.

A good workflow for managaging waypoints is to use tags to cleanly mark points in your timeline. I can't quite understand your last sentence but what you may want is diverge a branch from a previous point in time. To do this, use the handy checkout command:

git checkout <commit hash>
git checkout -b <new branch name>

You can then rebase that against your mainline when you are ready to merge those changes:

git checkout <my branch>
git rebase master
git checkout master
git merge <my branch>
Lai Yu-Hsuan

When I walked around GitHub, I saw many files. It seems a simple format file to express text and pictures.

But I googleed it and found nothing. I guess there is an editor or syntax explanation somewhere.

Where can I find the introduction to .md files?

Answered By: Dikei ( 174)

I believe is just a text file written in Markdown syntax.


I'm stuck behind a firewall so have to use HTTPS to access my GitHub repository. I'm using cygwin 1.7.7 on Windows XP.

I've tried setting the remote to, but pushing prompts for a password, but doesn't do anything once I've entered it. https://username:<password> and cloning the empty repo from scratch but each time it gives me the same error

error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing

Turning on GIT_CURL_VERBOSE=1 gives me

* About to connect() to port 443 (#0)
* Trying * successfully set certificate verify locations:
* CAfile: none
CApath: /usr/ssl/certs
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Closing connection #0
* About to connect() to port 443 (#0)
* Trying * successfully set certificate verify locations:
* CAfile: none
CApath: /usr/ssl/certs
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Closing connection #0
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing

fatal: HTTP request failed

Is this a problem with my firewall, cygwin or what?

I hadn't set the HTTP proxy in the Git config, however it's an ISA server that needs NTLM authentication, not basic, so unless anyone knows how to force git to use NTLM, I'm scuppered.

Answered By: Alexey Vishentsev ( 266)

The problem is that you do not have any of Certification Authority certificates installed on your system. And these certs cannot be installed with cygwin's setup.exe.

There are two solutions: 1. Ignore ssl certificate verification:

$ env GIT_SSL_NO_VERIFY=true git clone https://github...

2. Actually install root certificates. Curl guys extracted for you certificates from mozilla:

cacert.pem file is what you are looking for. This file contains > 250 CA certs (don't know how to trust this number of ppl). You need to download this file, split it to individual certificates put them to /usr/ssl/certs (your CApath) and index them.

Here is how to do it: With cygwin setup.exe install curl and openssl packages Execute:

$ cd /usr/ssl/certs
$  curl | awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > "cert" n ".pem"}'
$ c_rehash
Daniel Beardsley

I've been using Git for a bit now (hosting my own) and would love to have something like GitHub that I could setup for my own repos. I've seen GitWeb, but I just don't like using it all that much. Is there anything for Git that's as slick as Warehouse for SVN?

Answered By: Jakub Narębski ( 83)

I don't know about Warehouse, but there are many web interfaces for Git, see "Web Interfaces" section on Interfaces, frontends, and tools wiki page:

  • gitweb, which is developed together with git, and is written in Perl. Works both as CGI script, and legacy mod_perl script. There is duct tape (soon to be released as Girocco), which together with gitweb make for git hosting interface. I think it most commonly used web interface; it is used for example by
  • cgit is is a fast (caching) and lightweight webinterface written in C. It is used for example by
  • git-php and ViewGit are git web interfaces written in PHP.

If you are interested in more complete solution to hosting git repositories (like from what I can see Warehouse is), and you need source code (therefore GitHub is out), you can take a look into:

  • duct tape (soon to be released as Girocco), which is set of shell scripts
  • gitorious, which like GitHub is written in Ruby, and which provides similar functionality
  • InDefero, written in PHP, is a clone of GoogleCode with git, Mercurial and Subversion browser.
  • Atlassian Stash, Commercial (10 User "Starter Licence" available). Written in Java. Provides git repository and user credentials/permissions management, user SSH key management. Can integrate with Jira issues and use Jira user directory.
  • Assembla Repository Manager, Commercial ("Forever Free" 10 User License available). Ships as an OVF virtual machine. Provides git and svn repository and user credentials/permissions management. Can be expensively upgraded at any time into a full Assembla Portfolio installation.

So there are a few solutions to choose from.