Github stuff

Just a bunch of git related things (I keep forgetting how to do them!)

How to add new files to an existing Github repository

# first create your repository in github
cd ~/your-files-to-add/
git init .
git remote add origin git@github.com:yourname/yourrepo.git
git pull origin master
git add "list-of-files-to-add-to-github"
git commit -m "some comment"
git push

 

How to update a forked github repository from the web interface

If you have forked a github repository and need to update it do this:

  1. Login to your github 
  2. Navigate to your forked git repository
  3. Click “pull request” at the top
  4. in the “base repo” drop down, change it from the main one to your forked repository
  5. in the “head repo” drop down, change it from your forked repository to the main repository

How to checkout a single directory from a github repository

This is called sparse checkouts, it is possible but requires a little bit of fiddling.

cd ~/path-to-checkout-files-to/
git init .
git remote add origin git@github.com:yourname/reponame.git
git config core.sparsecheckout true
echo "folder-name-to-checkout" >> .git/info/sparse-checkout
echo "some/other-folder" >>  .git/info/sparse-checkout
git pull origin master

Leave a Reply

Your email address will not be published. Required fields are marked *