Public
snipts » git
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 --
-
∞ 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
-
∞ 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
-
∞ 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
-
∞ 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 -
∞ 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
-
∞ List added files in the index
git diff-index HEAD|awk '{print $5 " " $6}'|sed -n -e's/^A //p'
-
∞ List unmerged files
git ls-files -u|awk '{print $4}'|sort -u -
∞ 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>
-
∞ 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
-
∞ 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
-
∞ tracking branch
git checkout --track origin/serverfix
-
∞ git cat
#!/bin/bash git cat-file -p $(git ls-tree $1 "$2" | cut -d " " -f 3 | cut -f 1)
-
∞ GitHub merge
git checkout master git fetch <remote> git merge <remote>/master
-
∞ annotated git tag
git tag -a 20090101 -m "Update on 2009-01-01" -
∞ 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
-
∞ 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
-
∞ 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
-
∞ 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
-
∞ 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



MySQL in a Nutshell