Click here to Skip to main content
Click here to Skip to main content

Working with CodeProject Workspaces::Code (::GitMachine)

, 12 Jul 2014
Rate this:
Please Sign up or sign in to vote.
An explanation how to efficiently work with the ::Code App (::GitMachine) provided by CodeProject Workspaces
Prize winner in Competition "Best "Everything Else" Article of March 2014" (Second Prize level)
 This article is answering FAQs to the ::Code application of CodeProject Workspaces. If you have a question which is not directly related to content provided in this article, please use the Workspaces Forum on CodeProject. The CodeProject staff is frequently checking for new forum posts and you will be provided with a qualified answer a lot faster than if you posted your question as comment on this article. 
Thank you!

Content

Introduction

With CodeProject Workspaces Chris Maunder and his team are offering a whole new experience for you:
Maintain the code associated with your Articles, Tips, Tricks and References with the Workspaces::Code App and stay on top of your tasks with the built-in Workspaces::Task App. Even though Workspaces is still in its Beta state I decided to chunk out this quick working guide which of course is here to help you: Manage your code stored in the Workspaces Repository with Git. You can access CodeProject Workspaces at workspaces.codeproject.com. Important to know is that each Workspace contains two modules [per default]: ::Code and ::Tasks - You can add more of each, or just decide to stick with either one of them. This article focuses on the ::Code module and how it can be accessed with the Git Bash. An explanation about the Workspaces::Tasks App was written by Chris and can be accessed here.

Before you start

First of all, you need to get your preferred Git client - I decided to use the standard client (Git Bash),
developed by Git themselves. Get the version for your OS at the Git download page. If you want to stick with a GUI based Git tool you can pick one from the respective Git page. But remember that this article focuses on the usage of the CodeProject Workspaces with the Git Bash. It is also focused on Windows and a guide to git on Linux and OS X may be added later.

Install and configure Git [Windows]

This chapter explains the Installation and configuration of Git for Windows. First you need to execute the downloaded Git Installer, which should get you to the very first Window of the Installation Wizard:

After this, the real complicated bit (the real, base configuration) comes up. The settings I recommend in the following steps are best guesses, and depending on how baked and self-customized your system is you need to use different settings. You can mess up a lot alone in the first configuration section - I recommend you to check "Use Git Bash only" if you don't know what you should check. Else, make sure you know what you are doing.

Also, OpenSSH will work fine for 99% of the users. If you belong to the other 1% (or feel like you do), check your insurance first, and make sure that you really want to be in that 1% as second.

Now it gets tricky: Git allows you to replace CRLF (Windows line endings) with LF (Unix line endings). Read the window text carefully, and chose your setting according to the IDE you use. Hint: Visual Studio uses CRLF by default. As much as I'd like to, but I can't see what you use as IDE so you need to make your own choice here.

If you made it through the jungle, you are done: Git is now ready to be installed on your computer. Click "Next", and rejoice for the first time.

Git is afterwards installed to C:\Program Files (x86)\Git if you are using an x86 system, or C:\Program Files\Git if you are using an x64 system. Now if you have used the default settings and try to type "git" you will receive an error that the command was not recognized. This happens because Git uses its own little command prompt, which can be launched from the shortcut "Git Bash" which is located in the installation folder:

Double clicking the shortcut will bring up the Git Bash:

Now that we already have to Git bash up and running we can start by configuring our Git client. First of all you need to tell the client your CodeProject display name and your CodeProject Login email address:

git config --global user.name "USERNAME"
git config --global user.email "E@MAIL" 

Each line must be committed by hitting enter, and USERNAME must be replaced by your display name on CodeProject - Marco Bertschi, in my case - You must use the quotation marks, e.g. I typed

git config --global user.name "Marco Bertschi" 

Don't use any email for user.email - Use exactly the email address you use to login to your CodeProject account! Now that we are done with the boring prep work we can move on to the fun thing:

Setting up a completely new Workspace

Are you at the start of your project or want to port an existing project to a new, shinier home? Here you go, this chapter describes the setup of a new Workspace and guides you how you can add code to the new and shiny code home. At this point, I expect that you have set up the Git client as described above. At first, you need to create a local repository on your hard drive. I use to store all CodeProject related stuff under "C:\Code\CodeProject", and I want a repository called "Springlog" in the sub folder "Workspaces". The command to create this directory is

mkdir C:\Code\CodeProject\Workspaces\Springlog 

Of course you can just add the folder using the File System Explorer, too. To continue, the current folder must be set to the folder of the repository, I did that by typing cd <folderpath>, e.g.

cd C:\Code\CodeProject\Workspaces\Springlog 

A Workspace on CodeProject Workspaces must be set up before you can continue. Go to CodeProject Workspaces -> workspaces -> Create a workspace.

Afterwards you need to specify a name for your workspace, and it would be really great if you could give a brief description on what the code you submit does.

Remember the Name you give to your workspace, it will be a part of the URL used to access it.
At first you need to init Git - Type

git init   

in the Git Bash and hit enter. To link the local repository to an existing Web Repository you need to run

git remote add origin [Workspace URL]

You can find the URL of your workspace in the top right corner of the ::Code module in the Workspace start page.

In the case of the example the exact command to run is

git remote add origin https://git.codeproject.com/marcobertschi/thespringlogproject 

Note: Git uses the term "origin" as name (shortcut, if you want) for the URL you type. In the end you can't have more than one shortcut named "origin", so you might wanna name it "springlog_origin" (or whatever suits your needs).

Now we can add the files which are going to be part of the Web Repository. Copy all the files you want to upload to the directory you have created on your local hard drive and run

git add -A 

This command adds the files in the directory (e.g. C:/Code/CodeProject/Workspaces/Springlog) except the automatically created sub folder .git to the local repository. To pull up the changes onto the Web Repository you need to stage a commit and push the commit to the Web Repository.

Staging commits and push them to a Web Repository

Before you can push any changes to the Web Repository you need to stage at least one commit. You can see a commit as a snapshot of your local development status, allowing to store multiple sets of changes locally before you push them to the Web Repository. A commit can be staged by running

git commit -m "Commit message"

this command adds all changed files to the commit. Please remember to replace "Commit message" with your specific comment about the changes included in the commit. You can add multiple commits like that, and if you want to add only specific files to your commit you can run the command as

git commit [File 1] [File 2] -m "Commit message" 

After you have added at least one commit you can push the committed changes to the Web Repository.
If this is the first time you push from this specific local repository to the Web Repository you need to run

git push -u origin master 

The "-u" option means that Git remembers that you want to push this local repository to the specified Web Repository, allowing you to use

git push 

for any future pushes from the local repository to the Web Repository.

 Please note that the Git bash isn't showing your password while you are typing it, and it looks like your keyboard broke. This behavior is inherited from Linux systems - Just type your password and hit enter, even though it isn't showing up on screen.

Pull an existing repository to your local HDD

If you have an existing Web Repository and want to continue development you need to pull a copy from the Web Repository to your local hard disk. First you need to create a local folder where the Web Repo will be copied into:

mkdir PATH 

or

mkdir C:/Code/Repos

You can also just create the directory using the file explorer, if available. Afterwards switch to the created repository. Run

cd C:/Code/Repos 

Since you just made a directory (and not a local Repo) you need to type

git init

in order to make the directory available as Git Repo.
To specify the origin of the local repository you ned to run

git remote add origin REPO-URL

In case my Web Repository is located at https://git.codeproject.com/marcobertschi/thespringlogproject I need to run the command as

git remote add origin https://git.codeproject.com/marcobertschi/thespringlogproject

Note: Git uses the term "origin" as name (shortcut, if you want) for the URL you type. In the end you can't have more than one shortcut named "origin", so you might wanna name it "springlog_origin" (or whatever suits your needs).

After you have completed all the above written steps you finally can pull the content from the Web Repository to your own local repository:

git pull origin master 

Common Questions

Overview over the Code available in a Workspace

On the Home page of a Workspace you can see an Overview over the Code stored in it. This Overview provides you with a lot of information about the Code and the ongoing development:

The most important parts are listed below:

1 An overview about Commits, Branches, Contributors, Pull requests and so on

2 The unique URL of your Repository

3 Copy the Repository URL into the Clipboard

4 A list of the latest commits done to the project, including the commit comment

5 Shows who has contributed the most to the project

Where can I view code stored in a Repository?

You can download the Code stored in a repository with Git, or you can view it in your browser. To do the second, go to the Workspace which's code you want to see and click on "Code" in the panel at the left hand side.

This will get you to the web repository viewer which will display the code stored in the repository to you.

User management

Each Workspace allows you to easily collaborate with others. You can set permissions for other people with a CodeProject account to allow them editing the code in the repository, or the repository itself.

To get to the user management settings you need to click on the "Share with others" button on the top:




There you go, if you followed the instructions you are now on the page where you can add users to your workspace and give them a role in your project:


You can add users by typing their name into the box [1]. Before you add a user, you can also set their role, depending on what access actions they will be able to perform [2]. Currently there are four different permission levels:

  • Restricted user
    • Restricted users can only view the content of the repository, but not change it. This role is only applicable if your repository is a private one, otherwise every registered CodeProject user can view the content of your repository.
  • Regular user
    • Regular users can access apps and edit content (Tasks, but also code)
  • Administrator
    • Administrators can add, change, or delete apps.
  • Owner
    • The Owner role is assigned to the creator of the workspace and can't be assigned to other members. You can do everything an administrator can do, plus add or remove members from the Workspace or change their role.

In the overview below you can see the current users who have access to the workspace. The overview displays the user's real name [5], the display name [4] and the assigned role [3].

Points of Interest

When I started writing this Article I had no idea of Git, despite of how I can use the Git bash and do productive work with it. During the writing process I really learned a lot, not only about the Git commands but also about the core principles behind Git - Stacking commits locally until I push them to a Web Repo, for example, was a completely new but nevertheless sense making idea, which I am sure is a huge productivity enhancement. As a native TFS user I can say that I start liking Git more and more - It is simple, easy to set up and even easier to use.

During writing this Article I did a lot of research in parallel and eventually found some really good Reference reading, for Git newbies but also for experienced Git users:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Marco Bertschi
Software Developer (Junior)
Switzerland Switzerland
Software Developer (Swiss Federal VET Diploma), experienced with Qt C++, C#, RFC 5424 and Arduino Boards.
Music enthusiast, runner, part-time psychologist for friends, awesome guy.
Follow on   Twitter

Comments and Discussions

 
QuestionCannot input my password PinmemberCode and Coffee7-Jul-14 18:39 
AnswerRe: Cannot input my password PinprotectorMarco Bertschi12-Jul-14 9:48 
QuestionGit PingroupFranksLIC26-Jun-14 9:27 
AnswerRe: Git PinstaffKamil Burzynski26-Jun-14 21:08 
QuestionProblems with "Pull an existing repository to your local HDD" Pinmemberravenspoint9-Jun-14 3:11 
AnswerRe: Problems with "Pull an existing repository to your local HDD" PinprotectorMarco Bertschi9-Jun-14 3:45 
AnswerRe: Problems with "Pull an existing repository to your local HDD" PinprotectorMarco Bertschi10-Jun-14 1:04 
GeneralRe: Problems with "Pull an existing repository to your local HDD" Pinmemberravenspoint11-Jun-14 0:51 
GeneralRe: Problems with "Pull an existing repository to your local HDD" PinprotectorMarco Bertschi11-Jun-14 3:26 
GeneralRe: Problems with "Pull an existing repository to your local HDD" Pinmemberravenspoint11-Jun-14 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 13 Jul 2014
Article Copyright 2014 by Marco Bertschi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid