Sunday, January 20, 2013

How to show git branch/status information in bash

extension for terminal/command line to use git more effectively:

For Mac users, (zsh): https://github.com/olivierverdier/zsh-git-prompt

For bash(works fine for Ubuntu): https://github.com/magicmonty/bash-git-prompt
I do following update for /home/USER/.bash/gitprompt.sh :
PROMPT_START="$WHITE$Time12a $Yellow$PathShort$ResetColor"
PROMPT_END=" $ "

For simple branch show(works very fast), (link second comment):
Simply add following line it ~/.bashrc
PS1='[\u@\h`__git_ps1` \W]\$ '



Saturday, January 5, 2013

Gitolite - permissions examples

Attention: Gitolite version 2.
Deny permission completely(no access for clone) for user @trial user group, all other full access:


@trial  = denis


repo    my_repo
   - =   @trial
   RW+  =   @all
   config gitolite-options.deny-repo = 1


Give user Jenkins permission only for Read/Fetch/Clone, all other full access:

repo    my_repo
   R    =   jenkins
   -    =   jenkins
   RW+  =   @all

Forbid "git push --force" for 'master' branch only to avoid repository history damage, all other branches could be rewinded ('--force'):

repo    my_repo
   RW  master  = @all
   -   master  = @all
   RW+         = @all



Examples: site1, site2,

Friday, January 4, 2013

Hotkeys for terminal advanced usage

Web Source: http://allhotkeys.com/ubuntu_hotkeys.html

the most useful and less known commands:

1) Ctrl+D = Log out from the current terminal. In X, this may log you out after a shuting down the emulator.
It is very useful if you have a lot of open terminals(with ssh connection to remote server) and you want to logout from them quickly(without typing 'exit' in each on them)

2) Ctrl+R = History search (Finds the last command matching the letters you type).
Previously I used "history | grep my_command", but this looks like more elegant.

3)Ctrl+L = Clears terminal output.

Sunday, December 30, 2012

Install Sublime text to Ubuntu

Sublime text - text editor that Mac user love to use, so let try it in Ubuntu,
What I like:
- it is quick
- outline view of whole file on the right side.
- Columns/Block selection, how to.
- line numbers as out of the box functionality.

Instruction:

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

Wednesday, December 26, 2012

Git - merge till certain commit

Case: you need merge your master with with development branch but till certain commit(not till HEAD ) in development branch

it is simply:
-- I presume you are at development branch --
git checkout master
git merge 37e4218a4d51ad44952d30a5906cbe6b2e0a54d2

or do it by tag name:
git merge 0.5.10

and you will merge till this(37e421) commit, that is located in development branch.

Tuesday, December 18, 2012

Git commands to remember

Here I  will post command that usually use but sometime forget syntax, so rewriting them again with explanation help me to remember them :) :

remove all files from staging area - "git reset HEAD"

add to staging area only modified files - "git add -u"

remove all newly created files from working folder - "git clean -f"

change comment of the last commit - "git commit --amend"

get all remote branches to local repository - "git fetch"

create local branch base on existent remote branch - "git checkout -b development remotes/origin/development"

push to remote branch with 'force' after rebase - "git push --force origin SYS-551"

create new branch base on non commited changes - "git checkout -b short-status-form-sb" after that do "git add filepath ; ...."

push to remote newly created local branch - "git push origin my-new-feature"

show history of changes in terminal - "git log --oneline --decorate --graph"
show history of changes in UI - "gitk" or "gitk --all"

remove branch from local repository - "git branch -D SYS-551"

remove branch from remote repository  - "git push origin --delete SYS-551"

SVN style looks for logs output - "status -sb"

See all changes that are going to be pushed - "git diff --stat origin/master" or "git diff origin/master".

Get only the work your current topic branch has introduced since its common ancestor with master: "git master...test"

Revert one commit (revert changes that were done by commit) "git revert <SHA-1>"

Remove last commit completely from local repo - "git reset HEAD~1 --hard"

Find out which branch contains a change - "git branch --contains 50f3754"

Find out if a change is part of a release - "git name-rev --name-only 50f3754"

Get rid of all changes/commits in branch to remote git state "git reset --hard origin"

Convenient aliases, source:
git config --global alias.st "status -sb"
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.bra "branch -a"
git config --global alias.chp cherry-pick
git config --global alias.pr "pull --rebase"
git config --global alias.bl "blame -b -w"
git config --global alias.cia "commit --amend"
git config --global alias.lg "log --pretty=format:'%h was %an, %ar, message: %s' --graph"
git config --global alias.who "shortlog -s --"

from Daniil Yaroslavtsev:
git config --global alias.l "log --graph --pretty=format:'%Cred%h%Creset %C(bold blue)<%an>%Creset%C(yellow)%d%Creset %s %Cgreen(%cr)' --abbrev-commit --date=relative"

Friday, December 14, 2012

Gitolite - get access to repository for all users except for one

All is written in manual :), it only takes a bit time to read all, try a lot to make it work.

general description about rules: http://sitaramc.github.com/gitolite/rules.html
Nuances about deny meaning: http://sitaramc.github.com/gitolite/g2/aac.html#deny

Deny - does not forbid read access by default.

Mu config, to give access to all except for mihail (trial group) that have access only to project3:

@trial    =  mihail

repo    project1
        -       =   @trial
        RW+     =   @all
        config gitolite-options.deny-repo = 1


repo    project2
        -       =   @trial
        RW+     =   @all
        config gitolite-options.deny-repo = 1


repo    project3
        RW+     =   @all