Posts Tagged ‘git’

Articles

Checkout subdirectory in a git repository

In howto on Jul 13, 2016 by theoryl Tagged: , , ,

To checkout a subdirectory in a Git repository using sparse-checkout, follow these instructions

git remote add -f origin https://github.com/whoever/whatever.git
git config core.sparsecheckout true
echo /path/to/subdirectory >> .git/info/sparse-checkout
git checkout master

Alternatively

git clone https://github.com/whoever/whatever.git
cd whatever
git config core.sparsecheckout true
echo /path/to/subdirectory >> .git/info/sparse-checkout
git read-tree -mu HEAD

Also see this StackOverflow answer.

Articles

How to sync a forked git repository?

In howto on Jul 13, 2016 by theoryl Tagged: , , ,

To synchronize your forked Git repository with the upstream, follow these nice instructions on StackOverflow:

# Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:

git fetch upstream

# Make sure that you're on your master branch:

git checkout master

# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:

git rebase upstream/master

# If you don't want to rewrite the history of your master branch,
# then you should replace the last command with the following

#git merge upstream/master

# Now push your branch to your own forked repository

git push origin master

# If you've rebased your branch onto upstream/master you may need to
# force the push in order to push it to your own forked repository

#git push -f origin master

Articles

Remove sub directory from Git sparse checkout

In howto on Aug 28, 2014 by theoryl Tagged: , ,

If you have configured Git to use sparse checkout to checkout a sub directory, but later decided that you don’t really need that sub directory, here’s what to do:

1. first delete the sub directory
2. open .git/info/sparse-checkout , delete the sub directory name in the list
3. git read-tree -mu HEAD

If you don’t do this, Git will stage the deletion of the sub directory for the next commit.

Articles

Git aliases

In shared on Jan 17, 2014 by theoryl Tagged: , ,

Some useful Git aliases


[user]
name = ...
email = ...
github = ...

[alias]
a = add
ap = add --patch
am = am -s
c = commit
cs = commit -s
ca = commit --amend
co = checkout
b = branch -vv
l = log --graph --all --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n'
lt = log --graph --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n'
ll = log --graph --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n' -10 HEAD~6..HEAD
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --date=relative
lf = log --pretty=fuller
ls = log --pretty=fuller --stat
s = status
d = diff
ds = diff --stat
dc = diff --cached
dcs = diff --cached --stat
dp = show
dhh = diff HEAD^!
dhhs = diff HEAD^! --stat
doh = diff origin/master HEAD
dohs = diff origin/master HEAD --stat
rb = rebase
rbi = rebase -i
rbio = rebase -i origin/master
t = tag -a
tl = tag -ln1

[core]
editor = vim

#[push]
# default = simple

[color]
ui = auto

Articles

Gollum on Ubuntu/Linux Mint

In howto on Sep 11, 2013 by theoryl Tagged: , , , , , , , ,

Gollum is the wiki engine that is developed and deployed by GitHub. The codes are hosted at https://github.com/gollum/gollum. It supports many syntaxes, including Markdown, ReStructuredText, Textile, MediaWiki, etc. To install:

On Linux Mint 13 “Maya” (based on Ubuntu 12.04 “Precise Pangolin”), first get Ruby and RubyGems:

sudo apt-get install ruby1.9.1 ruby1.9.1-dev rubygems1.9.1

Then install Gollum via RubyGems:

sudo gem install gollum

An alternative to install Gollum is to build from source (taking version 2.5.0 as example):

git clone git@github.com:gollum/gollum.git
cd gollum
gem build gollum.gemspec
sudo gem install gollum-2.5.0.gem

If you build Gollum from source, you might also want to build its library from source (https://github.com/gollum/gollum-lib).

To use it, simply create a Git repository:

mkdir ~/Wiki
cd ~/Wiki
git init
gollum .

Now point the browser to http://localhost:4567/, and you have a fully functional Wiki site up and running. As a bonus, it is automatically versioned by Git every time you create/edit a Wiki entry.

One downside thus far is that Gollum doesn’t support multiple repositories and multiple users.

Read More »