|Deletions are marked like this.||Additions are marked like this.|
|Line 59:||Line 59:|
* To do a filtering where you pass through only one subdirectory:
# New temporary branch
git checkout -b new
# Actual filtering
git filter-branch --tree-filter 'rm -rf * .gitignore .doit.db.db ; git co -- gtfspy ; true' --parent-filter 'sed "s/-p 58ded83ba782.*//"' --prune-empty -f --
Git config file
[alias] autocommit = commit -av -m "Autocommit" --edit br = branch cm = commit -v co = checkout di = diff dic = diff --word-diff=color dis = !git --no-pager diff --stat diff-latex = difftool -t latex log1 = log --oneline --graph --decorate log1np = !git --no-pager log --oneline --graph --decorate st = status [diff] # wordRegex = [^[:space:]]+ # default is something like this. wordRegex = [a-zA-Z0-9_]+|[^[:space:]] [color] ui = auto [difftool "latex"] cmd = git-latexdiff \"$LOCAL\" \"$REMOTE\"
Pushing into a live branch
Sometimes you want to use git to update a "working copy", for example, pushing to a server to update the main website. You can not push to a checked out branch (well, you can, but that would involve overwriting local changes and other issues...). Instead, we use an "incoming" branch to push to, and merge that to the live branch using a post-receive hook. In the system below, push to the INCOMING_BRANCH, and each push will: merge INCOMING_BRANCH into LIVE_BRANCH, and then run whatever commands you put at the bottom to make it live.
vi .git/post-receive chmod a+x .git/post-receive
#set -x INCOMING_BRANCH=new LIVE_BRANCH=live # if we want to make sure we are on the "live" branch #git checkout live # if we want to make sure we are on the "live" branch cd .. ; unset GIT_DIR if [ "`cat .git/HEAD`" = "ref: refs/heads/$LIVE_BRANCH" ] ; then #echo "Merging into live branch" git merge $INCOMING_BRANCH fi # Enter your commands to update main below make
- When filtering a branch, if you want to get rid of an initial commit, do this:
git filter-branch --parent-filter 'sed "s/-p 09fdd9e.*//"' -- 09fdd9e..A
09fdd9e is the last "upstream" commit that you don't want included in the new branch. The parent filter says "a commit with that parent commit will now have NO parent commit. We filter only the commits after that one to the current branch A.
- To do a filtering where you pass through only one subdirectory:
# New temporary branch git checkout -b new # Actual filtering git filter-branch --tree-filter 'rm -rf * .gitignore .doit.db.db ; git co -- gtfspy ; true' --parent-filter 'sed "s/-p 58ded83ba782.*//"' --prune-empty -f --