Linux

Useful Bash Aliases for GIT

Linux, OSX, Tools

Switching from SVN to GIT can be awkward especially if your used to SVN shortcuts like
svn co for svn checkout and
svn up for svn update

the solution is these nifty terminal aliases.

git status, git add, git commit, and git checkout are such common commands that it is useful to have abbreviations for them.

alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gca='git commit -a'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
alias gp='git pull'
alias push='git push'
alias gr='git rebase '
alias gm='git merge '

alias got='git '
alias get='git '

Source(s):

How to use TAR and GZIP

Linux, OSX, tip, Tools

I’ve been doing a lot of server maintenance recently and have found myself having to archive and transfer file to and from different server, as a result I’m continually looking at the man page for TAR trying to figure out which exact flags to use in each situation.

See the guide below for a quick 101:

How to TAR a Directory

  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name

For example, you have directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:

$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog

Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory.

NB. the -v flag “Verbose” is optional  and prints a list of each item added or extracted to the console.

How to Extract a TAR

If you wish to restore your archive then you need to use following command (it will extract all files in current directory):

$ tar -zxvf prog-1-jan-2005.tar.gz

Where,

  • -x: Extract files

If you wish to extract files in particular directory, for example in /tmp then you need to use following command:

$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -

Source(s)

I can’t remember the exact source of this example but its been used and reused all over the web.. here’s a few places it maybe from: