Using Git with CodePlex

Git is a distributed version control system that is popular for open source projects. To learn more about how to use Git, the Pro Git site is a great reference. The following is a step-by-step guide to get started using Git for your CodePlex projects.

Step 1: Create your CodePlex project

Log-in to CodePlex and create a project. When selecting the source control, pick Git.

clip_image001[4]

Once your project is created, click on the Source Control tab. Click the “Git” link under the Source Control heading on the right of the page to bring up connection details:

clip_image003[4]

Take note of the Clone URL. We’ll be using this later.

Step 2: Set up Git

Download and install the latest Git tools for your operating system:

For the remainder of the guide, we’ll assume that you’re on a Windows system for screenshots.

After you’ve installed Git, you’ll want to provide Git with a username. Git uses this information to keep track of commit history, and CodePlex uses this to match commit history with CodePlex users. To do so, open the Git command line (Git Bash if you chose the default installation options for Git on Windows) and type the following command:

git config --global user.name "CodePlexUsername"

clip_image005[4]

Step 3: Clone the repository

Next, you’ll want to set up your repository on your local machine by cloning the repository on CodePlex. In the Git command line, change the directory to a folder where you want to store the source code of your project and then type the following git command:

git clone https://YourCodePlexUsername@CloneUrl NameOfFolder

where CloneUrl is the Clone URL you noted in Step 1, and NameOfFolder is the name of the folder where you want the source code to be stored. For example:

git clone MyAwesomeGitProject

clip_image007[4]

Since you haven’t yet published your project, you’ll have to enter your CodePlex password. Because your repository is empty, you’ll get a warning message, but that’s fine.

Step 4: Push to CodePlex

Go to your newly created directory, and add your source code. Stage your changes using git add. For example, let’s say you add a readme file to your directory:

cd MyAwesomeGitProject

notepad readme.txt

git add readme.txt

clip_image009[4]

Commit your changes with a commit message:

git commit -m "my first commit to CodePlex”

clip_image011[4]

Push your changes back up to CodePlex.

git push origin master

Type in your CodePlex password when prompted.

clip_image013[4]

Visit your project page on CodePlex and verify that your changes have been pushed by browsing to the source code tab.

clip_image015[4]

Last edited Mar 22, 2012 at 10:20 PM by jontsao, version 4

Comments

mcassidy May 23, 2012 at 5:13 PM 
If you're using Mercurial with hg-git, you can clone codeplex repos using:
hg clone git+https://git01.codeplex.com/MyAwesomeGitProject.git

mwrock May 6, 2012 at 6:48 AM 
It may also be helpful to note that in addition to cloning your empty repo to your local directory, if you already have code ready to push up to codeplex, its easier to do the following:
C:\dev\Project> git init
C:\dev\Project> git add .
C:\dev\Project> git commit -m 'my first commit'
C:\dev\Project> git remote add origin https://git01.codeplex.com/project
C:\dev\Project> git push -u origin master

Now your code is in your CodePlex Repo.

rohezal May 6, 2012 at 12:04 AM 
error: Cannot access URL https://git01.codeplex.com/opencltutorial2/, return code 22


Any Idea why?

cplotts Apr 24, 2012 at 8:31 PM 
I just wanted to say that when you use your username above ... drop the _cp ... otherwise authentication will fail when you push.

That is, my codeplex user name is cplotts for the above ... and not cplotts_cp.

Circe Mar 30, 2012 at 7:04 AM 
Qbus, how did you know what I was thinking? It is uncanny! I just finished reading this article on ReadWriteWeb about Codeplex offering Git
http://www.readwriteweb.com/hack/2012/03/codeplex-yes-codeplex-adds-git.php

Then I wandered on over here, expecting to see documentation for something closer to GitHub. But of course, GitHub merely uses the Git "paradigm". Despite the name, GitHub Not.Equal Git. I knew that, but I love GitHub, the UI is so pleasant. I took one look at this documentation, and thought to myself, "Eeeek! Looks like green screens!"

You were 100% correct, console commands ARE scary! Thank you so much for posting those two UI links. That was very thoughtful. Particularly since they are for Windows, which is what I use and like!
;o)

Qbus Mar 29, 2012 at 11:33 AM 
Git is really cool, but all these console commands can be scary!
So, if you don't want to console yourself all the way, here are two great Git UI clients for Windows.
http://code.google.com/p/gitextensions/
http://code.google.com/p/tortoisegit/

Happy coding :)