Sunday, November 9, 2014

How to Publish Existing Projects to GitHub

I had spent an hour or more trying to publish my existing projects to GitHub the first time doing it, so this is for anyone that wants to avoid the trouble and is a completely new to GitHub and Git.

First you will need the git utilities which can be found here: http://git-scm.com/

I assumed you are using Windows and installed it to the PATH as well; otherwise you will need to use the Git Shell.

You also need the GitHub app, which you should know where to get (hint: github.com).

This will be the easiest way to do it.

You can just use git shell but you'll need to manually register the machine on GitHub and use the git's add and commit calls. Also the GitHub's some nice additional features like code comparison and a GUI (I know GUIs sometimes get a bad rap from power users but sometimes they actually make things easier and shell)

The steps below are assume you:
  • have the above set up, obviously
  • have an existing C# project, but any project would be similar and you can probably figure it out
  • creating a new GitHub repo for the project
First open a command prompt (or git shell) and go to your project folder. This folder is has either the *.sln, If you're solution only has 1 project though you can use the folder with the *.csproj as the root.

I sometimes have projects with multiple child components each with their own .csproj, but the solution puts it all together and they really should be treated as 1 project. So for those, I would use the first choice.

In the folder, type and execute git init 

This creates a new local repository in the folder. Note the repo will be named the same as the folder it is created in.



In Explorer, go to the folder containing the project folder (1 level higher than the folder in which you created the repo)


Drag the folder into GitHub which will then list the files in the folder and sub folders.


You will see the files that are added, most likely you don't want the build files like bin/*, obj/*. You do this by creating a .gitignore file but you can use GitHub to do it for you:

With the new repo selected, on the top right, you should see a widget icon which when clicked it will display a menu. Click on the "Repository Settings..." option.


You should now see 2 columns, and large icons that say "Create ..."

Click on them and they will create the default files. I've never touched the Attributes but you may need to edit "Ignored files" if you have some custom files you want ignored.



You can add individual files with their exact name, or folders which need to be in the format: <folder name>/

You can also use * in the as a wildcard so "myFile*" would exclude any file beginning with "myFile"

"myFolder*/" would match any folder beginning with "myFolder", and all its subfolders as well.

Now once, this is done, exit the settings and the Files To Commit list should update appropriately.

When you have reviewed all the files, commit it to master by first filling out at least the Summary field (when that is filled out, the Commit button will be enabled).

You have now added the files to your local repository. You need to click "Publish Repository" for the project to be created on GitHub.


Then, the button will turn into "Sync" and you need to click this for your files to be added to GitHub.

Again, "Sync" actually copies the files (not Commit, not Publish Repository).

For subsequent commits, you follow a similar process, "Commit to master" will commit the changes to the local repo, "Sync" will send them to GitHub.


Bulk Rename Utility 1.0

Recently wanted to rename a bunch of similar video files and thought it would be nice to do a bit of programming (pretty much all weekend... but it was fun) to do it. The result is Bulk Rename Utility.

The program allows you to rename a bunch of files at once based on Filters (or rules).

Currently there are two types of filters but for the most part you only need RegexFilter anyway. TrimFilter I guess is more just to prove that multiple filters work :)

The RegexFilter searches the name for the parts that match the regular expression in SearchFor and replaces with the text in ReplaceWith. To delete the matches entirely, just leave ReplaceWith empty.

Also, if you have files loaded, it will use the first file's name as the default Preview text.

The TrimFilter trims a single character from the beginning and end of the name, not very exciting I know.

Note that filters are run in order, so if you had:

Original String: Hello World
Filter 1: World => Apple
Filter 2: Apple => Orange

The result would be "Hello Orange". And if you flipped the order, it would be "Hello Apple"

The program also allows you to save the filters so that it can be used again on other files.
Finally, you can remove multiple files from the list at once by using CTRL to select multiple items and clicking "Remove Selected".

Download: https://drive.google.com/folderview?id=0BwHjtARwf-GFV0ZidHplMF85TFE&usp=sharing

GitHub: https://github.com/allanx2000/BulkRename

Also all applications are built for .NET 4.0 Client Profile, unless otherwise stated. I've only tested it on Windows 8 x64... because I'm too lazy to install a x86 VM but it should work as it is compiled targeting Any CPU.