Thursday, August 29, 2013

HOW TO: Switch a cloned Git repo to your fork

Here we go, yo, so what's the scenario?

You clone a Git repository from, say, GitHub, to dive into the source code.  Eventually, you decide you would like to make some changes and submit a pull request.  You need to switch your repo to point to your fork. Here's how.

List the current remote(s)

Here we see I cloned the Jenkins project, which was itself forked from Kohsuke's account.

$ git remote --verbose
origin https://github.com/jenkinsci/jenkins.git (fetch)
origin https://github.com/jenkinsci/jenkins.git (push)
upstream https://github.com/kohsuke/hudson.git (fetch)
upstream https://github.com/kohsuke/hudson.git (push)

Replace the existing origin with your fork


$ git remote rm origin
$ git remote add origin https://github.com/olivierdagenais/jenkins.git

Replace the existing upstream with the old origin

...if applicable, of course.

$ git remote rm upstream
$ git remote add upstream https://github.com/jenkinsci/jenkins.git

Double-check the remote(s)


$ git remote --verbose
origin https://github.com/olivierdagenais/jenkins.git (fetch)
origin https://github.com/olivierdagenais/jenkins.git (push)
upstream https://github.com/jenkinsci/jenkins.git (fetch)
upstream https://github.com/jenkinsci/jenkins.git (push)

Monday, August 26, 2013

Visual Studio error message template

Visual Studio (among others) will recognize lines that follow a certain pattern in the output window and turn them into links that open an editor to the file and then position the cursor where the error occurred.

The general pattern used by the tools and recognized by Visual Studio is:

fileName(startLine,startColumn[,endLine,endColumn]): error errorCode: errorMessage
An example message would look like:

C:\Source\path\to\solution\project\FileWithCompileError.cs(154,20,154,26): error CS0103: The name 'result' does not exist in the current context
The endLine and endColumn are optional; presumably not all errors can be pinpointed to a range so accurately.