Change the remote for a repository:
git remote add origin git@github.com:rjwalls/REPO_NAME.git
#Or if origin exists already
# git remote set-url origin git@github.com:rjwalls/REPO_NAME.git
git push -u origin master
Make a copy of the repository files without any git information:
git archive master | tar -x -C /somewhere/else
Need to remove large files from your repo history? Check out bfg.
Checkout a particular commit-version of a file.
git checkout ASDFHDFS file.txt
Check the size of the repo.
git bundle create tmp.bundle --all
du -sh tmp.bundle
Get around the “Invalid certificate chain” error.
git config --global http.sslVerify false
Get the differences in the working version of a file.
git diff HEAD~1 file.tex
List the tracked files in the current directory.
git ls-files
Globally ignore all files named *.swp.
echo *.swp >> ~/.cvsignore
git config --global core.excludesfile '~/.cvsignore'
Remove *.swp files from a repository—assuming they are being tracked
already.
git rm -cached *.swp
Remove *.swp files from both current directory and repository.
git rm *.swp
Stash your local changes. This is useful when you need to go back to the original working state.
git stash save "the stash info"
Amend local commit; useful when you forgot to add some changes in the current commit.
# Used git ci -m "my commit" already
git commit -a --amend
Export the repository without the .git information.
git archive master | tar -x -C /somewhere/else
Check out a file from any commit (commits are identified by SHA1 hash of 40 characters).
git checkout commit_sha1 filename
Drop all the local changes since last commit and push to remote harsh.
git fetch origin
git reset --hard origin/master
Git Svn
git svn clone https://address.of.repo.com
Gotcha: The svn directory needs to have at least one commit or you will get errors when you clone.
Git and Latex
Generate a diff PDF for the working directory. Make sure you have the git-latexdiff wrapper installed.
git latexdiff HEAD~1 --
#Or
git latexdiff HEAD~3 HEAD --main paper/paper.tex --whole-tree -c"PICTUREENV=(?:picture|DIFnomarkup|lstlisting|lstinline)[\w\d*@]*"
Github Pages
Github pages is an awesome thing, but sometimes you don’t actually need a master branch for your project. For example, the repository for this site. First thing you need to do is set gh-pages to be your default branch on Github. You can do this by going to “Settings>Branches” from the repository page on Github. Once there, just select gh-pages using the drop down.
Now on your local repo do the following:
git checkout gh-pages
git branch -D master
git push origin :master
I got this tip from here.