Logo by Git
Use latexdiff
There is a git compatible version of latexdiff named latexdiff-vc
.
This compares the same latex documents in two different commits within a git repository.
See here for more detailed desription and a usage example.
Use merge
I often personally use git merge
to merge a draft that is written for a collaborative project that do not use git
for version control.
First of all, I push
all the modifications of the local files
git push origin master
Next, I make the master version back to the one corresponding to the period from which many people starts editing it.
git reset --hard (commit)
I make new branch on which I update the others modification to the draft
git branch (branch name)
git checkout (branch name)
cp (new draft) (old draft)
Finally, I make the master version to the newest to merge the modifications made by myself and others.
git checkout master
git pull origin master
git merge (branch name)
Remove the commit history file by file
Why did I need it?
At some point, I finished using bitbucket and transferred my repositories to github. One repository had a commit history that included a file larger than 100MB, which had been deleted in the newest commit. It did not cause any problem when I was using bitbucket, but did caused with github due to the size limitation. So, I needed to consistently remove all the commit information related to this large file.
What I did
I could find which file in the history had a large size using git_find_big.sh provided by Atlassian. I executed in the root of the repository
./git_find_big.sh
After identifying which file to be deleted, I executed
#!/bin/bash
TARGETS=(
"[target file name]"
)
target=$(printf " %s" "${TARGETS[@]}")
target=${target:1}
git filter-branch --index-filter "git rm -r --cached --ignore-unmatch ${target}" -- --all
IMPORTANT: please be aware that you take a back up of the repository before executing this, of course!