Category Archives: Git

Gollum – Auto sync to git remote repository

Update @ 2015-09-23: Frank suggested using incron to execute the sync base on file changes instead of time periods. Thanks!.

Whenever you have edited any page on Gollum, it will committed to the local repository which is checked out on the server. These commits WILL NOT be pushed to the Git Server. Similarly any push to the Git server will not sync to the repository running Gollum as it won’t execute git pull neither.

You may think of using the Git post-commit hook to trigger the synchronization whenever a commit is done but Gollum run Grit as the Git adapter and Grit doesn’t support hook.

A workaround suggested by Rod Hilton is to setup a cronjob and keep running the git push and pull on the server running Gollum.

So add the following sync.sh to your Gollum project root. Continue reading Gollum – Auto sync to git remote repository

Gollum – Add Git identity by running Gollum as a Rack appliaction

Gollum is a simple documentation app base on Git. I could write the docs in markdown and all changes would be governed by the Git repository.

But the application doesn’t support any authentication and that means there is no way to trace who has committed the code.

Kudos to Stephanie Collett who wrote a rackup file for Gollum such that it will prompt for user email before the user start editing. That email is stored in session and would be used as identifying during commit.

Here is the config.ru Continue reading Gollum – Add Git identity by running Gollum as a Rack appliaction

Git – Setup a bare repository which is writable by both user and group

We have made the HTTP protocol works for our git repository.

 

We need to made the files writable by Apache otherwise you could never push the commits back to the server.

To setup a new repository, we could flag it as a shared repository during initialization. Then we could change the repository root folder.

git init --bare --shared=group <new-repo>.git
chgrp -R <group> <new-repo>.git

Continue reading Git – Setup a bare repository which is writable by both user and group

Make Git work on HTTP protocol

Assume SELinux is disabled on your Git server…

The following setup is on CentOS and assume your Git repositories are all located under /data/repos.

1. Install Git and Apache.

yum install git httpd

 

2. Create the /etc/httpd/conf.d/git.conf.

# Git over HTTP
<VirtualHost *:80>
  SetEnv GIT_PROJECT_ROOT /data/repos
  SetEnv GIT_HTTP_EXPORT_ALL
  ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

  <Location /git/>
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile /var/www/passwd.git
    Require valid-user
  </Location>
</VirtualHost>

Continue reading Make Git work on HTTP protocol

Tig – Git interface on command line

It’s not easy to view the Git log in command line but most of the time is the most straight forward way or sometimes, the only way you could view the Git commit history.

Tig is a ncurses-based interface to view your Git repository.

Installation on OS X using Homebrew:

brew install tig

 

Installation on Ubuntu:

apt-get install tig

Continue reading Tig – Git interface on command line

Git – git rm all missing files

There is no git rm . to stage the deleted files in a Git repository. Here are some alternatives which could help you to achieve that.

1. Stage deleted files only.

git ls-files --deleted | xargs git rm 

 

2. Stage the modified and deleted files.

git add -u

 

3. Stage all newly added, modified and deleted files.

git add -A

 

Done =)

Reference: StackOverflow – Removing multiple files from a Git repo that have already been deleted from disk

Git – Ignore changes on a tracked file

Assume you Git repository contains the following 3 files.

  • file.txt
  • readme.md
  • init.conf

 

i want to retain the init.conf in the repository for initial checkout. After that, ignore further changes which is made on the local branch.

In the above case, .gitignore doesn’t work because it is only for untracked file which means you have to remove it that file from the Git repository.
Continue reading Git – Ignore changes on a tracked file

Git – Ignore some folders and files in the current working copy

We can always use the .gitignore to exclude files which we do not want to check in into the repository. But sometimes the repository is only read only and you dun want your files to be appeared in the git status command. A simple solution to exclude those files in your current working copy. This could be done by editing the .git/info/exclude. Here is an example for my Drupal 8 installation.

.git/info/exclude
Continue reading Git – Ignore some folders and files in the current working copy