Apr 13
In git, to clone a remote branch, fetch it to a branch of the same name:
git fetch origin demo:demo
git fetch origin demo:demo
git checkout --theirs filename # or git checkout --ours filename # or, for an interactive interface git mergetool
git submodule add /path/to/remote local_name
git clone /path/to/repo-with-submod cd repo-with-submod git submodule init git submodule update
git checkout sha1 filename
git show sha1 filename
git show sha1:filename
> git checkout sha1:filename
fatal: reference is not a tree: sha1:filename
git diff HEAD^ file # shows differences between previous and current version of file.
git show HEAD^ file # WRONG: prints a blank line. No messages, no warnings. git show HEAD^:file # RIGHT: (note colon) shows the previous version of file.
git config branch.master.remote origin git config branch.master.merge refs/heads/master
# On the server, to avoid having copies of local files. git --bare init # On the client. git remote add origin ssh://hostname/path/to/repo git push origin master
git reset --soft HEAD^
git config --global core.excludesfile ~/.gitignore
git log -p filename
git show HEAD^:filename