Tag Archives: Git

How to embed images in GitHub Readme Files

In this screencast I’ll show you how to add images to your GitHub Readme files. You can use the Markdown or HTML syntax for this, I’ll show you both versions. Make sure to upload images to your own repository and provide the relative path to them.

Here’s the syntax:

In Markdown

In Markdown syntax, use the following example to embed an image:

In HTML

GitHub also supported the HTML syntax, which uses the standard IMG tag. Pasting HTML code in a website is always a little tricky, but let me try:

Should you have spaces in your file names, you can replace them with %20, just like in standard HTML (like “file%20name”).

Now go and make those Readme.md files look handsome!

Catch this episode on my WP Guru Podcast:

How to place an existing Xcode project under Version Control with Git (and ignore files you don’t want to track)

Usually when you create a new Xcode Project you can choose to setup a new Git repository. This is the best and easiest way to track your changes. However if you have a project that is not under version control you can create a Git repository retrospectively.

This is fairly straightforward using the Terminal app on your Mac (under Applications / Utilities):

  • cd into the directory where your project resides
  • then initialize an empty repository (git init)
  • and add the entire directory to it (git add .)
  • commit your changes (git commit -m “initial commit)

So far so good. However Mac has a hidden directory called .DS_Store in every directory – we may not want to track that. Plus, every time you make a minor UI change in Xcode (such as open a group in the file explorer or something that is not relevant to your actual code) Xcode tracks this change in a file called UserInterfaceState.xcuserstate, and we definitely do NOT want to track that.

To tell Git that we don’t want those two things, we’ll amend our previous instructions a bit:

  • cd into the directory where you project resides
  • create a file called .gitignore
  • add each file or directory on a new line
  • then create, add and commit your files to Git

Let’s assume my project is called MyProject, then the steps are as follows:

If you have already committed all your files and forgot to setup the .gitignore file you must manually remove the files/directories you don’t want from being tracked. This is how you’d do that:

Replace myusername with your own system user name obviously, and MyProject with the actual folder in which your project resides.

How to place an existing Xcode project under Version Control with Git (and ignore files you don’t want to track)

Usually when you create a new Xcode Project you can choose to setup a new Git repository. This is the best and easiest way to track your changes. However if you have a project that is not under version control you can create a Git repository retrospectively.

This is fairly straightforward using the Terminal app on your Mac (under Applications / Utilities):

  • cd into the directory where your project resides
  • then initialize an empty repository (git init)
  • and add the entire directory to it (git add .)
  • commit your changes (git commit -m “initial commit)

So far so good. However Mac has a hidden directory called .DS_Store in every directory – we may not want to track that. Plus, every time you make a minor UI change in Xcode (such as open a group in the file explorer or something that is not relevant to your actual code) Xcode tracks this change in a file called UserInterfaceState.xcuserstate, and we definitely do NOT want to track that.

To tell Git that we don’t want those two things, we’ll amend our previous instructions a bit:

  • cd into the directory where you project resides
  • create a file called .gitignore
  • add each file or directory on a new line
  • then create, add and commit your files to Git

Let’s assume my project is called MyProject, then the steps are as follows:

If you have already committed all your files and forgot to setup the .gitignore file you must manually remove the files/directories you don’t want from being tracked. This is how you’d do that:

Replace myusername with your own system user name obviously, and MyProject with the actual folder in which your project resides.

How to use Xcode with a remote Git server

Xcode_iconImagine you’ve created a project in Xcode with a local Git repository. Now you’d like to put this online so that others can collaborate with you. How do you do that?

This has been puzzling me for a while, and there doesn’t seem to be a clear documentation on this subject – so I’ve decided to take some notes as I figured it out. Here are step by step instructions on how to make it work.

All we need is a server running Git and SSH credentials to that server to get started.

Continue reading How to use Xcode with a remote Git server

How to install Git on CentOS

Git-Logo-2ColorGit is a superb version control system that’s tightly integrated into Apple’s Xcode. To collaborate with some coding buddies of mine we wanted to setup a central remote storage on my Plesk server so we could all contribute to the code.

Since we did not want to share our code with the public we wanted to make it secure. So secure in fact that we could contribute from coffee shops around the world, hence we decided to use Git with SSH. This is probably the easiest and most straightforward way for read/write access to Git remotes: no daemon to setup, to Firewall to tweak – all we needed was a set of SSH credentials and a server running Git with a bit of space.

Continue reading How to install Git on CentOS

How to add version control to an existing project in Xcode

Setting up a local GIT repository:

Open Terminal and change to the directory where your project is located (cd /path/to/your/project). Then use the following shell commands:

NOTE: as of Mountain Lion you need to install the Xcode Command Line Tools for this to work (under Xcode Preferences – Downlaods – Components).

Setting up a local SUBVERSION repository:

Subversion cannot place an existing directory under version control. Instead you need to create a new directory which serves as the subversion repository. You then checkout a working copy from this repository, work with it and then commit your changes back to the repository.

  • Open Terminal and and create a new directory to hold your repository (i.e. mkdir repos)
  • inside this directory create three sub-directories called trunk, tags and branches (i.e. repos/trunk, repos/branches, repos/tags)
  • copy your existing Xcode project into the trunk folder
  • enter ‘svnadmin create’ inside your main repository directory (i.e. in repos)
  • enter ‘svn import’

NOTE: Subversion has one extreme drawback: it sucks. Again for any of this to work in Mountain Lion you need to install the Xcode Command Line Tools (under Xcode Preferences – Downlaods – Components).