Sign up to create your own snipts, or login.

Public snipts » git The latest public git snipts.

showing 1-20 of 49 snipts for git
  • git: resolve unmerged by checking out one or the other version
    git ls-files -u --abbrev=1 '*.jpg' | ack "\d+\s+[^\s]+\s+3\s+([^\s]+)" --output="\$1" | xargs git checkout --theirs --
    

    copy | embed

    0 comments - tagged in  posted by dennari on Mar 03, 2010 at 11:02 a.m. EST
  • backup all git repositories that are in one folder
    #!/bin/bash
    
    BACKUP_FOLDER="/home/srvadm/p2backups"
    NUM_GROUPS="30"
    
    cd "$BACKUP_FOLDER"
    
    echo "backup at: `date`"
    
    for i in `ls`; do
    	if [ -d "$i" ]; then
    		echo "backing up repository: $i"
    		cd "$i"
    		git pull
    		cd ..
    	fi
    done
    

    copy | embed

    0 comments - tagged in  posted by prauber on Feb 25, 2010 at 5:55 a.m. EST
  • adds a specifiable number of groups to a gitosis server
    #!/bin/bash
    
    ############################################################
    ##                                                         #
    ## author:      Patrik Rauber                              #
    ## email:       rou_pi@hotmail.com                         #
    ## website:     www.patrikrauber.ch                        #
    ##                                                         #
    ## script for generating as much gitosis repositories      #
    ##  as you need.                                           #
    ##  the user specified in the GITOSIS_GROUP_MEMBERS will   #
    ##  be able to read from and write to each of the repos.   #
    ##                                                         #
    ## repos will be named groupX where X is a number from     #
    ##  1 to $2 (can be entered at startup                     #
    ##                                                         #
    ## the script assumes that you can manage gitosis          #
    ##  (that means you are logged in as the user that is      #
    ##  authorized to update the configuration of gitosis      #
    ##                                                         #
    ## after setting up gitosis, the repositories are          #
    ## initialized too and ready for work (ready for git clone #
    ############################################################
    
    # the git remote servername (from where to check out the repos)
    GIT_SERVER="$3"
    
    # check out gitosis admin into empty directory
    cd /tmp
    git clone "$GIT_SERVER:gitosis-admin.git"
    cd gitosis-admin
    
    
    # write the corresponding number of groups into the conf file
    
    # the filename of the conf file.
    GITOSIS_CONF="gitosis.conf"
    # the name of the members that should be able to admin each repo
    GITOSIS_GROUP_MEMBERS="$4"
    # read the number of groups as first passed argument from commandline
    NUM_GROUPS="$1"
    # get the git ignore file path from the commandline
    GIT_IGNORE="$2"
    
    
    # create groups and repository in the gitosis.conf file
    for i in `seq -w 1 "$NUM_GROUPS"`; do
    	echo "[repos group$i]" >> "$GITOSIS_CONF"
    	echo "description = repository of group $i" >> "$GITOSIS_CONF"
    	echo >> "$GITOSIS_CONF"
    	echo "[group group$i]" >> "$GITOSIS_CONF"
    	echo "members = $GITOSIS_GROUP_MEMBERS" >> "$GITOSIS_CONF"
    	echo "writable = group$i" >> "$GITOSIS_CONF"
    	echo >> "$GITOSIS_CONF"
    	echo >> "$GITOSIS_CONF"
    done
    
    
    # update the gitosis file: push changes back to server
    git commit -a -m "adding users for p2 lecture to gitosis"
    git push
    
    # remove the gitosis directory
    cd ..
    rm -Rf gitosis-admin
    
    #initialize each repository we created above.
    
    for i in `seq -w 1 "$NUM_GROUPS"`; do
    	mkdir "group$i"
    	cd "group$i"
    	git init
    	git remote add origin "$GIT_SERVER:group$i.git"
    	# in order for the repo to be created it must not be empty
    	# therefore we add the .gitignore file
    	cp "$GIT_IGNORE" .gitignore
    	git add .gitignore
    	git commit -a -m "Initial import."
    	git push origin master
    	cd ..
    	rm -Rf "group$i"
    done
    	
    

    copy | embed

    0 comments - tagged in  posted by prauber on Jan 26, 2010 at 5:20 a.m. EST
  • Git Basics
    # init a git repository
    git init
    
    # add file to repository
    git add <filename>
    
    # commit all changes
    git commit -a -m <message>
    
    # change to previous revision
    git checkout <revision>
    
    # give current revision a name
    git tag <name>
    
    
    
    # create new branch
    git branch <branch>
    
    # switch to branch
    git checkout <branch>
    
    
    
    # checkout remote repository
    git clone <url>
    
    # checkout changes from remote repository
    git pull
    
    
    
    # list all files under version control
    git ls-files
    

    copy | embed

    0 comments - tagged in  posted by lucastheis on Dec 25, 2009 at 4:00 a.m. EST
  • gits from server backup per ssh
    # run 'git-archive.sh' on server
    scp -r -P 1234 user@192.168.0.1:~/git/*/*.tar.gz /g/git
    

    copy | embed

    0 comments - tagged in  posted by dalord on Dec 24, 2009 at 5:54 a.m. EST
  • Include Git repo in existing folder (e.g. C:\Users-repo)
    git init
    git remote add origin <path_to_repo>
    echo -e "[branch \"master\"]\n\tremote = origin\n\tmerge = refs/heads/master" >> .git/config
    git pull
    

    copy | embed

    0 comments - tagged in  posted by dalord on Dec 18, 2009 at 9:37 a.m. EST
  • List added files in the index
    git diff-index HEAD|awk '{print $5 " " $6}'|sed -n -e's/^A //p'
    

    copy | embed

    0 comments - tagged in  posted by kergoth on Dec 17, 2009 at 5:32 p.m. EST
  • List unmerged files
    git ls-files -u|awk '{print $4}'|sort -u
    

    copy | embed

    0 comments - tagged in  posted by kergoth on Dec 17, 2009 at 5:32 p.m. EST
  • Git merge stages
    1 - Common ancestor
    2 - HEAD
    3 - Remote
    
    rev-parse syntax - :<stage>:<path>
    Check out stage 2 (HEAD) - git checkout --ours <path>
    Check out stage 3 (Remote) - git checkout --theirs <path>
    

    copy | embed

    0 comments - tagged in  posted by kergoth on Dec 17, 2009 at 5:31 p.m. EST
  • Small script to show the current branch when we are inside a git repo.
    #!/bin/bash
    
    GITOUT=`git branch 2>&1 | grep \* | awk '{ print $2; }'`
    
    if [[ $GITOUT ]]; then
        echo -n "($GITOUT)"
    else
        echo -n ''
    fi
    

    copy | embed

    3 comments - tagged in  posted by marcelor on Dec 13, 2009 at 2:14 p.m. EST
  • create new repository
    update gitosis.conf and commit
    ----------
    
    mkdir myproject
    cd myproject
    git init
    git remote add origin git@YOUR_SERVER_HOSTNAME:myproject.git
    
    # do some work, git add and commit files
    
    git push origin master:refs/heads/master
    

    copy | embed

    0 comments - tagged in  posted by chawei on Nov 18, 2009 at 10:38 a.m. EST
  • tracking branch
    git checkout --track origin/serverfix
    

    copy | embed

    0 comments - tagged in  posted by dalord on Nov 17, 2009 at 11:35 a.m. EST
  • git cat
    #!/bin/bash
    git cat-file -p $(git ls-tree $1 "$2" | cut -d " " -f 3 | cut -f 1)
    

    copy | embed

    0 comments - tagged in  posted by goerz on Oct 17, 2009 at 8:25 p.m. EDT
  • GitHub merge
    git checkout master
    git fetch <remote>
    git merge <remote>/master
    

    copy | embed

    0 comments - tagged in  posted by dalord on Oct 16, 2009 at 5:38 p.m. EDT
  • annotated git tag
    git tag -a 20090101 -m "Update on 2009-01-01"
    

    copy | embed

    0 comments - tagged in  posted by dalord on Oct 06, 2009 at 9:33 a.m. EDT
  • Git fetch
    # Se adisiona nuevo repositorio
    git remote add otro http://other.com
    git fetch otro
    git checkout FETCH_HEAD # Se revisar
    git merge FETCH_HEAD
    

    copy | embed

    0 comments - tagged in  posted by boriscy on Sep 21, 2009 at 3:37 p.m. EDT
  • how to create a git repo on a server under msysgit on windows
    cd /e/language/Project/src
    git init
    vim .gitignore      # *.pyc, *~
    git add .gitignore  # ...
    git commit -m "Initial commit"
    
    cd ../..            # /e/language
    git clone --bare Project/src project.git
    scp -r -P 1234 project.git user@192.168.0.1:~/git/language
    # delete 'Project' in Eclipse
    git clone ssh://user@192.168.0.1:1234/~/git/language/project.git project/src
    # recreate 'project' in Eclipse
    

    copy | embed

    0 comments - tagged in  posted by dalord on Sep 20, 2009 at 5:11 a.m. EDT
  • managing remote git branches
    # to publish a branch on the central server:
    git push origin devel-something:refs/heads/devel-something
    
    # to remove a remote branch you created in Git just push to it like:
    git push origin :name-of-branch
    

    copy | embed

    0 comments - tagged in  posted by spechard on Sep 04, 2009 at 4:04 a.m. EDT
  • make backup of all my github repos
    #!/bin/bash
    for NAME in backup.pl bmconverter.py convert_encoding.py \
    decay fortune.py git-graph gmail_archive.py liberator \
    mail.pl pdfWriteBookmarks pidgin2adiumlog procimap pyala \
    stoptimer texmf texpreview vimrc; do
        rm -rf $NAME.git
        git clone --bare git://github.com/goerz/$NAME.git $NAME.git
        (cd $NAME.git \
            && git remote add --mirror origin git://github.com/goerz/$NAME.git)
    done
    

    copy | embed

    0 comments - tagged in  posted by goerz on Aug 18, 2009 at 4:17 p.m. EDT
  • php pre-commit git hook
    #!/bin/sh
    # This hook checks for syntax errors before committing
    
    if git-rev-parse --verify HEAD 2>/dev/null >/dev/null; then
      against=HEAD
    else
      # Initial commit: diff against an empty tree object
      against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
    fi
    
    for f in `git diff-index --cached --name-only $against | grep -e '\.php$'`; do
      if [ -f $f ]; then
        php -l $f
        if [ $? -gt 0 ]; then
          exit 1
        fi
      fi
    done
    
    exit 0
    

    copy | embed

    0 comments - tagged in  posted by danielrmt on Aug 17, 2009 at 2:53 p.m. EDT
Sign up to create your own snipts, or login.