Skip to content
Greg Flynn edited this page Mar 6, 2023 · 15 revisions

How to create a shared repo

New repo

git init --bare --shared=all $repodir

Edit a repo to be shared

chgrp -R foo $repodir
chmod -R g+rw $repodir
chmod g+s `find $repodir -type d`
gitk --all 
git stash list
git stash show <stash_hash>
git stash show -p <stash_hash>
git stash apply <stash_hash>
git stash save “foo”
git stash apply stash^{/foo}
git stash pop
git stash drop

Merging branches

git checkout master
git merge dev
git push
git checkout dev

git fetch

Git branch handling

get all of the branch names pulled down

git branch -r

get updates for all of the remote branches

git fetch --all

Push to a branch that does not exist on the remote

git push -u origin HEAD

Get short hash

git rev-parse --short HEAD

Merge one file

git checkout A
git checkout --patch B foo.txt
(Note if foo.txt does not exist do not use --patch)
or
git merge-file file1 original file2

Diff committed but not pushed files

git difftool --staged

View history

git log --patch -2  # is the number of commits to view
git log --stat -2
git rev-parse --short HEAD

Submodule tips and tricks

Revert submodule to pushed version

git submodule update

Sometimes you may need the -init flag

See what's going on:

git submodule status
symbol meaning
+ Not initialized (run git submodule init)
- Local changes not committed
U Conflicts in the submodule
No confilcts

Always use ssh instead of https

vi ~/.gitconfig

[url "ssh://git@github.com/"]
    insteadOf = https://github.com/

Damage control

Push only some commits?

git push origin local_ref:remote_branch

Local_ref could be any of the following:

master~3
master~~~
a specific hash
Or even more

Bundle

git bundle create "test" master

Git LFS

git lfs migrate info

Additional resources

Clone this wiki locally