Reply to comment

Life With Git

Update to my evolving list of notes on using git in day to day development. In some cases these are just the best methods I've found thus far, comments and suggestions are welcome. Sorry for the raw format. :) Phasing use of cogito out for raw git usage, most of it is now gone.

Getting Set Up

Edit ~/.ssh/config:

Host git.dangerouslyinc.com
User herk
Port 2223

Checking out:
git clone git+ssh://git.dangerouslyinc.com/git/wuja

Identify yourself:
git repo-config user.name "Awesome Haxor"
git repo-config user.email "ahaxor@dangerouslyinc.com"

Update:
git pull

Commit locally:
git-commit -a

Workflow

  • Work in branches.
  • Git pull in master to keep up to date.
  • Rebase branch against master.
  • Merge branch into master if pushing. (i.e. with commit access)
  • Format patch in branch if not pushing, wait for changes to appear in master via a pull.

Branching

List:
git branch

Create 'new' branch:
git branch new

Switch to branch:
git-checkout new

Publish local branch:
git push git+ssh://git.dangerouslyinc.com/git/revelation splashid:splashid

Checkout branch elsewhere:
git pull git+ssh://git.dangerouslyinc.com/git/revelation splashid:splashid

Merge master into branch:
git-merge master

Generating Patches

git-format-patch origin

Reverting Uncommitted Changes

git-checkout file-to-revert
git reset HEAD <file>

Diff

Generate diff between two commit IDs:
cg diff -r 0fa7b047ad8968f5996029071e04cb9b4f2831b9..234cde4eb65cc903e40a98f4d87eea9ae28f7ef4

Diff most recent commit:
git diff HEAD^ HEAD

Tags

Create and push a tag:
cg tag 0.0.5
git push --tags

Repositories

Tracking svn:
git-svn init svn://url
git-svn fetch
git-clone rhn.git newrepodir
git-svn dcommit

Creating a new remote repository:
# Upload .git dir
git --bare update-server-info
chmod +x hooks/post-update

Misc

Create a tarball for release:
git archive --format=tar --prefix=wuja-0.0.8/ HEAD | gzip >~/rpmbuild/SOURCES/wuja-0.0.8.tar.gz

Clone to send to someone:
git clone --bare my-project

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.