Quickies

[categories] [index] [all (531)] [latest]

Git
  1. # Exclude the build directory
    build/*
    
    # Exclude temp nibs and swap files
    *~.nib
    *.swp
    
    # Exclude OS X folder attributes
    .DS_Store
    
    # Exclude user-specific Xcode 3 and 4 files
    *.mode1
    *.mode1v3
    *.mode2v3
    *.perspective
    *.perspectivev3
    *.pbxuser
    *.xcworkspace
    xcuserdata
    
  2. $ git add -u
    
  3. $ git log --format='%aN' | sort -u
    
  4. $ git shortlog -n -s
    
  5. $ git push --delete origin MY_TAG
    
  6. $ git commit --amend -m "new message"
    
  7. Works with GitHub:

    $ git pull
    $ git tag -d THE_TAG
    $ git push origin :refs/tags/THE_TAG
    $ git tag THE_TAG
    $ git push origin THE_TAG
    

    Source: http://www.nax.cz/2011/01/15/move-a-remote-git-tag/

  8. Add an alias to display pretty logs

    $ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
    

    Display pretty logs

    $ git lg
    

    Display the lines that changed

    $ git lg -p
    

    Source: http://coderwall.com/p/euwpig?i=3&p=1&t=git

  9. git tag -d TAG_NAME
    delete remote tag 'TAG_NAME'
    git push origin :refs/tags/TAG_NAME
    

    or

    git push --delete origin TAG_NAME
    git tag -d TAG_NAME
    
  10. $ git reset --hard
    
  11. #!/usr/bin/sh
    
    ORIGIN=$HOME'/Dropbox/dropbox.git'
    CLONE=$HOME'/Projects/dropbox'
    
    mkdir -p "$ORIGIN"
    cd "$ORIGIN"
    git init --bare
    
    git clone "$ORIGIN" "$CLONE"
    
    cd "$CLONE"
    touch test.txt
    git add test.txt 
    git commit -m "Initial commit"
    git push origin master
    
  12. $ echo 'opendiff "$2" "$5" -merge "$5"' > ~/bin/opendiff-git.sh
    $ chmod a+x ~/bin/opendiff-git.sh
    $ git config --global diff.external ~/bin/opendiff-git.sh
    

    Now, git diff should open FileMerge:

    $ git diff