Git cheat guide

A great way to share and use opensource code is through GitHub. Here are some tips on getting started.

How to update remote Github with changes from local copy

Creating a Github repository is fairly straightforward. Once this is cloned to a local location, you will want to synchronise any changes.

  1. To synchronise the remote with local, run: git pull origin master
  2. To synchronise local with remote, run:
    • git add .
    • git commit -m "Added interesting files"
    • git push origin master

Folders appear greyed out on GitHub

This happens when you push a repository containing folders which in turn have .git files within them. In Git, this is known as a submodule. Typically, a single repository should contain a single .git file located in the top level directory. To fix this, for a submodule named submodule-name, do the following:

  1. Delete the .git file in submodule-name
  2. git rm --cached submodule-name
  3. git commit -m "Remove submodule entry"
  4. git add submodule-name
  5. git commit -m "Add sub fixed module-name folder"
  6. git push origin master

One thought on “Git cheat guide

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s