Posted to tcl by patthoyts at Wed Oct 01 21:25:07 GMT 2008view raw
- * Setting up
- Make sure to configure git with your id.
- git config --global user.name "Pat Thoyts"
- git config --global user.email patthoyts@users.sourceforge.net
- (see the windows section too).
- * Import a cvs repository into git
- This is done using cvsps:
- cvs -d:local:/opt/mirror/tcludp co -d tcludp.cvs tcludp
- cd tcludp.cvs
- git cvsimport -k -C ../tcludp tcludp
- * Windows configuration
- On windows we want to use plink so set GIT_SSH=c:\opt\bin\plink.exe
- Ensure that on the server it will run git commands for non-interactive
- logins. On my Solaris box I had to add the path into /etc/default/login.
- On Windows git prefers that EDITOR be a full path:
- set EDITOR=c:\opt\emacs-21.3\site-bin\gnuclientw.exe
- To get proper line ending handling ' git config --global core.autocrlf true'
- then update all the files. For a repository that I had already
- checkout with unix line endings I deleted everything then did
- 'git reset --hard' but there might be a smarter method.
- * Publishing a repository
- On the server, create a bare repository:
- mkdir /opt/gitrepos/xyzzy && cd /opt/gitrepos/xyzzy
- git --bare init
- chmod +x hooks/post-update
- touch git-daemon-export-ok
- edit the description file to have a useful name.
- On the dev machine, add the remote repository as 'origin'
- git remote add origin ssh://pat@cvs.patthoyts.tk/opt/gitrepos/xyzzy
- and configure as a tracking branch:
- git config branch.master.remote origin
- git config branch.master.merge refs/heads/master
- Now you can push your code to origin from master
- git push origin master
- and pull later:
- git pull
- * Publishing a local branch
- On the remote site, create a bare repository:
- cd /opt/gitrepos
- mkdir gitk
- cd gitk
- git --bare init
- echo 'My gitk mods' > description
- back on your working machine:
- git remote mymods ssh://cvs.patthoyts.tk/opt/gitrepos/gitk
- git push mymods
- This configures a remote repository called 'mymods' and then we push our
- current branch to the named remote repository (as we are working on
- branch mybranch this creates a mybranch branch in the remote).
- * Basic workflow
- Edit files then add them to the index 'git add .' or 'git add filename'.
- Once the changeset is ready, 'git commit' it and write a decent
- message. The first line should be suitable for a one line description,
- then put more details in subsequent lines. Dont be shy after the
- first line. The first word of the first line tends to be some kind of
- keyword identifier.
- 'git rm filename' removes files (and marks the index appropriately)
- 'git mv filea fileb' renames files and sets up the index.
- 'git reset' undoes work from the index. So to junk uncommitted changes
- from the index, use 'git reset --hard'
- To switch to a branch, 'git checkout branchname'
- 'git diff' - see changes in working tree
- 'git diff branch' see changes between this and the named branch
- * Conflict resolution
- If git fails to merge then git status will report the files as
- outstanding. Edit them to fix the problems (removing conflict markers)
- and then use 'git update-index filename' to update the index. Once
- you're done then you can 'git commit'.
- * Log message editing
- If the log message is messed up, 'git commit --amend' will let you
- edit the last commit message. Probably best done before any 'git push'.
- 'git commit -s --amend' will let you signoff the commit in case you
- didn't do that already.
- * Branch merging
- To cleanly move a patch branch up to the current head we use rebase
- So if we are on tip213, 'git rebase master' moves the branch point and
- reapplys the patches. If we run into merge problems and get conflicts
- then resolve them and use 'git rebase --continue'.
- * Extending git with aliases
- We can add some useful aliases quite easily. For instance, we can have
- 'git ci' be commit and 'git branches' list all branches.
- 'git config --global alias.ci commit'
- 'git config --global alias.branches "branch -l"'