Link Search Menu Expand Document

GitHub Standard Fork & Pull Request Workflow: https://gist.github.com/Chaser324/ce0505fbed06b947d962

GIT

Useful commands

Here is a list of most useful GIT commands for me when working with projects on github.

Get latest changes from origin:

git pull / git pull origin

Update fork on github:

git push myfork

Create new branch:

git branch mybranch / git checkout -b mybranch

Update branch on github:

git push myfork mybranch

Rebase branch to master:

git checkout mybranch
git rebase master

Remove branch:

git branch -d mybranch
git push myfork :mybranch

Bundles

Create bundle:

git bundle create repo.bundle master

Create bundle from last 10 days:

git bundle create repo.bundle --since=10.days master

Create repository from bundle:

git clone repo.bundle -b master repo

Verify the bundle:

git bundle verify repo.bundle

Pull from the bundle:

git pull repo.bundle master

Branching

This post describes very useful branching model that can be used with GIT:

http://nvie.com/posts/a-successful-git-branching-model/

Converting between tabs and spaces

It is very easy to convert between tabs and spaces automatically when committing and check-outing text files with GIT. GIT allows it with the attributes mechanism:

http://git-scm.com/book/ch7-2.html

http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs

To configure this behavior all you need is:

  1. Place ‘expand’ and ‘unexpand’ commands in your ‘PATH’ environment variable. For Windows they are part of GnuWin32 CoreUtils package: http://gnuwin32.sourceforge.net/packages.html

  2. Define needed GIT filter names. These are examples if you want tabs locally and two or four spaces in the repository:
    • git config --system filter.tabspace2.clean "expand --tabs=2 --initial"
    • git config --system filter.tabspace2.smudge "unexpand --tabs=2 --first-only"
    • git config --system filter.tabspace4.clean "expand --tabs=4 --initial"
    • git config --system filter.tabspace4.smudge "unexpand --tabs=4 --first-only"
  3. Apply settings to your local repository.
    • Create .git/info/attributes file inside your local repository directory and add following line(s) to it: *.<extension> filter=tabspace2 where <extension> is file extension than will be filtered.
  4. If you have any changes, commit them and then checkout all files to have filtered version on a disc: git checkout HEAD -- **

Encrypting

Encrypting with transcrypt.

The steps to setup encrypted repo:

git init
transcrypt

The password is stored locally in .git/config file.

The patterns describing which files to encrypt are stored in .gitattributes file.

The encrypted files will be all files in all subdirectories except the root folder. Also files with .unencrypted in their name will stay unencrypted.

#pattern  filter=crypt diff=crypt merge=crypt
*/** filter=crypt diff=crypt merge=crypt
*/*.unencrypted* !filter !diff !merge

Added all files to the repo:

git add .

Verified list of encrypted files:

transcrypt --list

And then normally commited and pushed the files.