Monday, 29 November 2010

Trash folder in ubuntu

It might be a good idea to set the default download folder of the browser to be the trash folder, so that you can quickly empty the folder. In ubuntu, the trash folder is in [user home dir]/.local/share/Trash/files.

Sunday, 28 November 2010

Chinese to English Translation

1. 蜂胶: Propolis ([ˈprɔpəlis]), resinous mixture that honey bees collect from tree buds, sap flows, or other botanical sources. It is used as a sealant for unwanted open spaces in the hive.
2. 皮蛋: Preserved egg
3. 分散圈Circle of confusion [photography]

Tuesday, 23 November 2010

git usages

1. Fixing un-committed mistakes
$ git reset --hard HEAD
This will throw away any changes you may have added to the git index and as well as any outstanding changes you have in your working tree.

If git reset takes a commit name as its parameter, it sets the current head to the specified commit and optionally resets the index and working tree to match. It defaults to HEAD (a keyword that refers to the most recent commit to the branch you're in).

Use --soft option when you want to stage all the previous commits but not commit them. This gives you a chance to modify the previous commit by adding to or taking away from it.

With --hard, it removes the commit from your repository and from your working tree. It's the equivalent of a delete button on your repository with no "undo". It's like the commit never happened, so it should be used with care.

2. Fixing commits
$ git commit --amend -C HEAD
This amends the previous commit, and keeps the same log message. "-C commit" takes an existing commit object, and reuses the log message and the authorship information when creating the commit.

3. Reset and checkout
$ git reset [commit] [--] path 
With a path parameter, git reset resets the index entries for all paths to their state at [commit]. (It does not affect the working tree, nor the current branch.)

This means that git reset paths is the opposite of git add paths.

After running git reset paths to update the index entry, you can use git-checkout(1) to check the contents out of the index to the working tree. Alternatively, using git-checkout(1) and specifying a commit, you can copy the contents of a path out of a commit to the index and to the working tree in one go.

So generally, use git checkout paths to revert changes in the working tree and use git reset paths to unstage changes.

A good explanation of reset and, its difference with checkout is here.

4. Tracking remote branch
Tracking when creating a new branch:
The full syntax is:
$ git checkout -track -b [local branch] [remote]/[tracked branch]
Simpler version is:
$ git checkout -t origin/branch
Setting up tracking for an existing branch:
& git branch --set-upstream branch upstream/branch