Categories
AWS Git Source Control

Getting started with AWS CodeCommit

Amazon is always creating new products and services. On November 2014, AWS announced new tools to help developers manage their source code and deployments. One of those tools was CodeCommit, a managed revision control service that hosts Git repositories.

On July 2015, AWS announced thru their blog that CodeCommit was available for production use.

Let’s create a new repository to see CodeCommit in action:

  1. Create new repository
    – Sign in to the AWS Console, and go to Developer Tools > CodeCommit
    – Click on Get Started link
    – Enter a repository name and description
    CodeCommit
  2. Shared the new repository
    – To connect to your new Git repository, you have 2 options: SSH and HTTPS. To keep it simple, let’s go with HTTPS.
    – Create a customer managed policy for your repository. Follow this article for complete instructions.
    – Create IAM Group and assign users to that group. Follow this article for complete instructions.
  3. Clone CodeCommit repo locally
    – If you are on windows, you can use the command and type:
    $ git clode https://git-codecommit.us-east-1.amazonaws.com/v1/repos/yourRepoName
  4. Now you are ready to start making changes.

If you have used Git before, you can continue using the same tools as before. Github and Bitbucket also allow you to host public and private repositories. With AWS, all repositories are private and need specific permissions to be setup with IAM policies and groups.

I’m still playing with this new AWS service and plan to write more in-depth articles on it.

 

Categories
Git Github open source

My fellow developers, ask not what your community can do for you, ask what you can do for your community

JFK

One of the most famous quotes from JFK is “My fellow Americans, ask not what your country can do for you, ask what you can do for your country.” This quote has inspired generations to be more involved in public service. It has inspired us to do more for our country. To be better citizens.

We can also apply the same quote to the software industry.

“My fellow developers, ask not what your community can do for you, ask what you can do for your community.”

Lately, I’ve been thinking of the impact the open source community has in our lives. There are thousands of open source software created by the community. The majority of these professionals do not get paid to work on these projects. They work on those projects because they are solving problems. They enjoy solving those problems. They are not waiting for others to solve those problems.

I want to inspire developers to start contributing back to the community. To help you do that, I have listed 3 easy things you can do to contribute to open source projects:

1. Documentation
Currently, the place to go to contribute to open source projects is github. Find a project that interest you. Once you find your project, read the documentation. I have seen many projects without a readme file. Go ahead and create one. If there is a readme file in place, see if you can spot any grammar errors. If you find any issues in the readme file, update the file with your corrections. If you need help getting started with github, read github’s bootcamp tutorial here.

2. Donate Money
Another way to give back to the community is to donate money. Many projects have a donate button in their front page. If you find an interesting project but they don’t have a donate button, get in touch with the project owners. Most likely they will accept donations.

3. Test
You can also test open source projects. You can play the role of QA tester. Developers don’t do a great job testing their software. For example, web sites are difficult to test because there are so many browsers to test in. You can test the web site with different browsers. If you find any issues while testing, see if you can figure out why it is failing. Open source projects need you for this kind of work.

I hope these words help you find the inspiration to start contributing back to the community. Be a better citizen.

Categories
ASP.NET C# code General Git Tips

Show me your progress with your commits

Git Commit

I’m currently working in a new application. It’s an ASP.NET MVC site written with C#. We are using the following technologies: Windows Communication Foundation, Knockout, Bootstrap, PostgreSQL, and Git.

I’m working on a new feature that will require me to make changes to the UI, javascript files, add new database tables, add service methods, add unit and integration tests. In other words, I have to modify all layers in our application.

To accomplish this task, I decided to try something different. I want to show my progress with my git commits. I want to complete small tasks and then commit my changes. For this specific task, I started writing a falling integration test. This failing test forced me to create the new database tables needed. After creating the tables, I ran the tests again and this time everything was back to green. At this point, I’m ready to commit these changes. This commit is the beginning of my work and it gets me closest to the final goal. I go ahead and commit this change.

commitTableCreation

After adding the database tables, sql scripts to generate them, and some unit tests, I’m ready to start adding service methods, data contracts, etc. For this task, I follow the same technique as above. My unit tests pass and I have not broken the build so it is time for another commit. With this second commit, I’m feeling productive. I have accomplished something. I can show my progress to my boss or team members with these small commits.

On the other hand, working for a long time without committing your changes, makes me nervous. What would happen if your hard drive fails? It happens all the time. I think we all have experienced losing our work. Many times it was something other than a hardware failure. It was a human error. For example, we deleted some files that were not in source control by mistake.

That’s why I like to commit often. As long as my project builds and my unit tests pass, I’m going to commit my small changes. I know that these commits don’t fulfill a complete feature, but they take me a step closer to my finish line.

After a few commits, I have accomplished enough back-end code that I can concentrate on the UI. Here is the initial version of the UI:

ContractSurvey

It is not perfect. I know that changes are inevitable. I would say that right now I have completed 80% of the task needed to bring this work to completion. I have 20% more to go and I can see the finish line. Seeing the finish line motivates me to do my best and finish strong.

I urge developers to commit small changes and commit often. Remember that these small changes will help you accomplish your goals sooner rather than later.

Categories
General Git Visual Studio

Visual Studio 2013 Git tip

visualStudioNoSupportSsh

I started a new project using Visual Studio 2013 and git. Our repository is hosted at Atlassian’s bitbucket. They also have a nice git client for windows that supports ssh and https. I downloaded that tool and was able to setup my repository using ssh.

Since Visual Studio 2013 has built in integration with Git, I was under the impression that ssh was also supported. I was wrong. Microsoft is using the open source library called libgit2 and that library does not have the ssh features to support it.

If you try to pull or push from a git ssh repo in Visual Studio, you will see the following error message:

An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error).
This transport isn’t implemented. Sorry

After searching online, I found out that this issue is not caused by Microsoft’s Visual Studio. It is the responsibility of libgit2. To work around that issue, you can update the url by updating the config file. To do that, find your .git folder (it might be hidden) and inside that folder, open the config file using notepad. Find the url and you will see that it starts with “git…”. Now find the https url and update it. Now close the config file and you should be able to do all the git operations inside Visual Studio.

I hope you find this tip useful.

Categories
Git open source Source Control Tips

Ignoring files with Git

GitIgnore

Git ignore allows you to specify files or folders that you don’t want to track with git. Some of the files that we don’t want to track are files that differ from one developer to another. They might be files resulting from a build. Other files might be artifacts that will change every time you build your project.

For example in Asp.Net projects, all of the dll files go inside the bin folder. Some of the dll files might be coming from a public nuget repository while others are private. Adding the bin folder to the .gitignore file will notify Git to ignore that folder and all of its contents.

If you are using Git, you can create a new file called “.gitignore” and place it in the root of your project. Now add [Bb]in/ to the first line of the file and save it. From now on, any files that reside in Bin or bin folder will be ignore or untrack by Git. There is a public repository at github called gitignore that has common settings for different languages. There is one for Visual Studio and you can find the project here. You can take a look at those settings and copy those to your project.

To read the official Git documentation, go to the gitignore page. I hope this article helps you gain more knowledge about Git and its features.

Categories
Git Source Control Team Foundation

Team Foundation checkout vs Git checkout

Source Control Checkout

I have a friend that has been using Team Foundation Server to manage his projects for a long time. He knows all the commands to create branches, merge, annotate, get latest, checkout, etc. However, when we started using Git, he was expecting the checkout command to perform the same action as Team Foundation.

In Team Foundation, the checkout command allows you to make changes to a file and also specify a lock type. In visual studio 2012, I see 2 options for lock type:

– Unchanged – Keep any existing lock and
– Check In – Allow other users to check out but prevent them from checking in

After you have selected the lock type, you can click the “Check Out” button and the file will be in edit mode and ready for you to make changes.

In Git, the checkout command is use to switch/create a new branch. If you want to switch to an existing branch, you can run the following command:

$ git checkout existingBranchName

If you want to create a new branch and switch to it, you can run:

$ git checkout -b newBranchName

To see the full list of available options for the checkout command, visit the official git documentation site @ http://git-scm.com/docs/git-checkout.

Hopefully this will help other developers using git coming from a Team foundation background.