git howto usage guide
git config core.trustctime false
git core.filemode false
git config user.name "Alice Bob"
git config user.email Alice_bob@example.com
git config --global user.name "Alice Bob"
git config --global user.email Alice_bob@example.com
git config core.whitespace nowarn
Execute:
git config --global core.autocrlf input
git config --global core.safecrlf true
Execute:
git config --global core.autocrlf true
git config --global core.safecrlf true
git config user.name ""
git config user.email ""
git config --global user.name ""
git config --global user.email ""
git config --global user.name "Petr Bob"
git config --global user.email petr_bob@example.com
##Git-svn workflow
##Git SVN manualy
git init
svn ls -R | grep -Z -v '/$' | xargs -0 git add
OR # svn ls -R | grep -v '/$' | xargs git add
git commit -m "message"
##git subnmodule
git init .
git submodule add https://github.com/opscode-cookbooks/python.git cookbooks/python
git submodule add https://github.com/opscode-cookbooks/yum.git cookbooks/yum
$ git fetch --tags
•
$ latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
•
$ git checkout $latestTag
https://gist.github.com/piscisaureus/3342247
To your origin add:
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
Or:
git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"
git config --global --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"
To fetch only one pr:
git fetch origin pull/7324/head:pr-7324
Explained:
git fetch
git branch -b aBranchName origin/aBranchName
git archive master | bzip2 >source-tree.tar.bz2
git archive --format zip --output /full/path/to/zipfile.zip master
to previous commit (destroying/updating workdir) - without HARD it just update HEAD and do not touch workdir
git_WORK_TREE=$PWD git reset --hard bc16dd2db065fcd1718c7e621e89e5ac61497a2e
mkdir -p git/example.git
cd git/example.git
git --bare inito
git remote add exampleserver ssh://exampleuser@example.com/~/git/example.git
git push exampleserver master
git remote add philomat git://github.com/philomat/django-cms-2.0.git # start tracking remote repo
git fetch philomat # fetch data of the repo locally
git cherry-pick efd7e5 # apply commit to active branch
git remote rm philomat # stop tracking remote repo (until next time... :-)
git pull https://github.com/USER/PROJECT/ BRANCH
alternatively: http://stackoverflow.com/questions/6022302/pull-requests-from-other-forks-into-my-fork
git remote add otherfork git://github.com/request-author/project.git
git fetch otherfork
git cherry-pick <first-SHA1> <second-SHA1> <etc.>
Use git rebase. Specifically:
git remote add upstream "https://github.com/opscode-cookbooks/openldap.git"
git fetch upstream
git merge upstream/master master
#or
git rebase upstream/master
From:
master A - B - C - D - E
To:
newbranch C - D - E
/
master A - B
To new branch:
git branch newbranch
# Go back 3 commits. You *will* lose uncommitted work.*1
git reset --hard HEAD~3
git checkout newbranch
WARNING The method above works because you are creating a new branch with the first command: git branch newbranch. If you want to use an existing branch you need to merge your changes into the existing branch before executing git reset --hard HEAD~3. If you don't merge your changes first, they will be lost. So, if you are working with an existing branch it will look like this: Moving to an existing branch:
git checkout existingbranch
git merge master
git checkout master
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.
git checkout existingbranch
WORKSPACE=~/hg2g/cli/myparty/projects/poc_myorg-cloud2/workspace_dev cd $WORKSPACE ./_mount_dev-wkst.sh
git svn clone https://gator.blueit.cz/myorg/svn/cloudpilot_src/trunk/solution/apde blueit-apde.git
###git clone blueit-apde.git $WORKSPACE/_sshfs_dev-wkst/apde_workspace2
git reflog XXX
######################################################################### ######UPDATE SVN FROM PETRS' WKST #########################################################################
git svn fetch -all
git svn renase
git svn checkout -b newFeature
##MODIFY git commit git checkout master git merge newFeature git svn dcommit
######################################################################### ######UPDATE SVN FROM DEV WKST #########################################################################
##On Developement workstation ############################### git branch -b dev
git rebase master ## PRIDANO POZDEJI
git checkout master
git merge dev
##On Petr's computer ############################### WORKSPACE=~/hg2g/cli/myparty/projects/poc_myorg-cloud2/workspace_dev cd $WORKSPACE ./_mount_dev-wkst.sh cd blueit-apde.git cd blueit-custom_web.git
git checkout -b merge-myorgdev
git pull dev-wkst master
git status
git checkout master
git merge merge-myorgdev
git svn dcommit
git branch -d merge-myorgdev
######################################################################### #####UPDATE DEV WKST FROM SVN #########################################################################
##On Petr's ############################### WORKSPACE=~/hg2g/cli/myparty/projects/poc_myorg-cloud2/workspace_dev cd $WORKSPACE ./_mount_dev-wkst.sh cd blueit-apde.git cd blueit-custom_web.git
git branch -d merge-svn
git checkout -b merge-svn #new
git svn fetch --all
# do commit ? merge ?
git svn rebase master #new
git checkout master #new
git merge merge-svn #new
git branch -d merge-svn
git push dev-wkst master:remoteUpdates
##On Dwks ############################### git checkout master git merge remoteUpdates git branch -d remoteUpdates