Git

From Sigmon

Jump to: navigation, search

Contents

Quick Ref

git clone ssh://sigmon@wrenchies.net/data/git/chibeers.git
git push origin master
git pull origin master
git archive --format=tar --prefix=git-1.4.0/  HEAD | gzip >git-1.4.0.tar.gz
git reset --hard origin/master
 git config --global user.email "you@example.com"
 git config --global user.name "Your Name"
git push --tags

Initialize Repo

server# cd /srv/git/repo/code
server# git init
client# cd ~/code
client# git init --bare
client# git add *
client# git commit -a -m' initial import for ... '
client# git remote add origin sig@$SERVER:git/code
client# git push origin master

Command Reference

git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git config --list
git branch -a

Tasks

Convert to bare repo

cd myrepo
git config --bool core.bare true
rm -rf *


add a origin

Say you have a local repository that you git init'd and committed to (ie, it has no origin)

mkdir -pv /data/development/myproject
cd $_
git init

hack hack hack

git add *
git commit -a -m' initial release '

All you have to do is give this repo an origin like so:


git  remote add origin watermelon.grepped.org:/data/gitrepo/myproject
git push --all

Then tell git how to merge origin changes:

vi .git/config

add this:

[branch "master"]
  remote = "origin"
  merge = refs/heads/master

Ensure you can pull

git pull


Change default remote

git remote set-url --push origin <remoteurl>
git remote set-url --push origin watermelon.grepped.org:/data/gitrepo/chef-runner

Change both pull and push

git remote set-url  origin watermelon.grepped.org:/data/gitrepo/chef-runner
  • Change "master" so git pull works
git remote add master watermelon.grepped.org:/data/gitrepo/chef-runner

Then add a branch:

[branch "master"]
  remote = "master"
  merge = refs/heads/master


http://blog.jrock.us/articles/Git%20merging%20by%20example.pod

References

Personal tools