Skip to content

Posts from the ‘Version Control’ Category

10
Aug

GIT command autocomplete in mac

In your home folder create / update .profile with the follow

if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
  . /usr/local/git/contrib/completion/git-completion.bash
fi

GIT_PS1_SHOWDIRTYSTATE=true

PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '

if the /usr/local/git/contrib/completion/git-completion.bash is missing you can get that from here

(Courtesy bitsandpix.com)

30
Nov

my .gitconfig

Creating a good .gitconfig file is always a pain in the ass. So I thought of sharing my gitconfig file with world. This gitconfig file is a result of lot of googling and reading

[user]
  name = Jose Antony
  email = jose@joseantony.com

[alias]
  # nice log output
      lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative



  # Search for a given string in all patches and print commit messages
  # example: search for any commit that adds or removes string "foobar"
  #     git searchcommits foobar
  # example: search commits for string "foobar" in directory src/lib
  #     git searchcommits foobar src/lib
  # example: search commits for "foobar", print full diff of commit with 1 line context
  #     git searchcommits foobar --pickaxe-all -U1 src/lib
  searchcommits = "!f() { query=\"$1\"; shift; git log -S\"$query\" \"$@\"; }; f \"$@\""

[color]
  ui = auto

[color "branch"]
   current = yellow reverse
   local = yellow
   remote = green

[color "diff"]
  meta = yellow bold
  frag = magenta bold
  old = red bold
  new = green bold
  #Highlight whitespace in diffs
  whitespace = red reverse

[color "status"]
  added = yellow
  changed = green
  untracked = cyan

#Highlight whitespace in diffs
[core]
  whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
24
Nov

GIT – xcode project file

I have worked on iPhone application full time since last year, Most of that time I spent working on team with multiple developers. And we have been strugling to keep the .pbxproj file in sync across the team. A bit of googling, we ended up in creating a .gitattributes file with the following content

*.pbxproj -crlf -diff -merge

The truth is that it’s way more harmful to disallow merging of that .pbxproj file than it is helpful. As you say, when you add a file unless other people get that file, they have to also add it to their project – in an application of any size, that sucks and it also takes away a huge benefit of source code control in that you cannot really revert to a complete earlier project state just through git.

The .pbxproj file is simply JSON (similar to XML). From experience, just about the ONLY merge conflict you were ever get is if two people have added files at the same time. The solution in 99% of the merge conflict cases is to keep both sides of the merge, which for git at least simply involves removing any >>>>, <<<<, and ==== lines. In fact this is so common that I have created a simple shell script to fix a .pbxproj file in a merge state from git, I run this from within the project directory (at the Classes level):

#!/bin/sh

projectfile=`find -d . -name 'project.pbxproj'`
tempfile="${projectdir}/project.pbxproj.out"
savefile="${projectdir}/project.pbxproj.mergesave"

cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile
cp $projectfile $savefile
mv $tempfile $projectfile

Worst case if it fails (you ask XCode to load the project and it fails to load), you simply delete the .pbxproj file, check out the master from git, and re-add your files. But I’ve never had that happen in many months of use with this script, again working full time on iPhone applications with several other developers.

(Courtesy stackoverflow.com)