Skip to content

Instantly share code, notes, and snippets.

@anscii
anscii / howto_git
Created August 6, 2012 09:35
github short how-to
Самый основной метод:
1. Форкаете репозиторий github.com/user1/project, получаете github.com/you/project
2. Уже форкнутый репозиторий сливаете себе на комп:
git clone git@github.com:/you/project project
3. Создаёте отсылку на «родительский» репозитарий, например как на upstream
git remote add git@github.com:/user1/project upstream, чтобы потом сливать изменения с «родителя» себе git pull
http://habrahabr.ru/post/125799/#comment_4147240
upstream master
4. Создаёте новую ветку
@anscii
anscii / gist:3774770
Created September 24, 2012 07:31
Svn stash
http://blog.jayfields.com/2008/02/using-patch-as-subversion-stash.html
to make a stash:
1) add all new files
2) create a patch:
svn diff > patch_name.patch
3) revert all changes
svn revert -R .
to unstash apply a patch:
@anscii
anscii / mass-git-cherry-pick-bash
Created March 21, 2013 09:09
Mass git cherry-pick
#!/bin/sh
for BRANCH in br1 br2
do
git checkout $BRANCH
git cherry-pick master
git push origin $BRANCH
done
@anscii
anscii / gist:5211717
Created March 21, 2013 09:11
Clone repo with stored username and password
git clone https://username:'password'@github.com/username/repo.git
@anscii
anscii / expect_svn_up.sh
Created July 26, 2013 10:49
svn up with auto svn+ssh password input via expect
#!/usr/bin/expect
spawn svn up
expect {
"username@svn.domain.com's password:*" {
send -- "password\r"
exp_continue
}
eof {
exit 0}
@anscii
anscii / mass_svn_up.sh
Last active December 20, 2015 06:48
Mass svn up with auto svn+ssh password input via expect
#!/bin/bash
for PROJECT in Proj1 Proj2
do
echo "##############"
echo "Starting ${PROJECT} update..."
cd /home/username/httpdocs/services/projects/${PROJECT}
expect <<- DONE
spawn svn up
expect {
git diff --no-prefix > patchfile
then apply the patch:
patch -p0 < patchfile
If you have an existing "git diff" patch file that was created without the "--no-prefix" option, you can apply that patch via:
patch -p1 < patchfile
this will ignore the default a/ b/ source prefixes.
#!/bin/bash
find . -type f -printf '%p\n' | while read file; do
oldfile=$(basename "$file")
newfile=$(echo "$oldfile" | sed 's/OLDNAME.jpg/NEWNAME.jpg/g')
if [ ! "$newfile" == "$oldfile" ]; then
mv "$file" "${file%$oldfile}$newfile"
fi
done
@anscii
anscii / gist:7467721
Last active December 28, 2015 07:58
Loop through git branches and pick specific string from every branch
#!/bin/bash
# list all branches
git for-each-ref --format='%(refname:short)' refs/heads |
while read branch; do
# if [[ $branch == ru_template32 ]]; then
# exit 0
# fi
echo $branch
git checkout $branch
@anscii
anscii / mass_android_app_create.sh
Created November 14, 2013 15:06
Script for creating and building several android app build from single template app. Data for every app should be provided in csv file. Script creates new branch for every app, replaces necessary images (logos, icons, splash screens etc), makes changes in source files (change ids, names, colors etc), renames app, builds it and places final signe…
#! /bin/bash
# path to project dir
base_path=/home/username/apps/android_template/
# path to main app project
proj_path=${base_path}MainActivity/
# path to res dir
res_path=${proj_path}res/
# path to dir with images for all necessary branches
img_path=/home/username/apps/images/