Notes about Git

From OpenPetra Wiki
Revision as of 15:25, 27 October 2009 by Pokorra (talk | contribs) (→‎Manuals)
Jump to navigation Jump to search

Manuals

Issues

Branches for development of OpenPetra

# first make sure we are on the main branch
git checkout master
# create a local branch that is called mynewbranch
git branch mynewbranch
# switch to that branch
git checkout mynewbranch
# create the branch also on the remote repository
git push ssh://..../openpetraorg/openpetraorg/ mynewbranch:refs/heads/mynewbranch
# change config so that future git push will go into correct remote branch
git config branch.mynewbranch.remote ssh://..../openpetraorg/openpetraorg
git config branch.mynewbranch.merge refs/heads/mynewbranch
# push changes in local branch to remote branch
git push

# make your changes in the branch, commit to branch
git commit -a
# push branch to remote branch
git push
# switch to master
git checkout master
# get latest from master
git pull
# merge from branch
git merge mynewbranch
# push to master
git push
# switch to branch again
git checkout mynewbranch
todo: get the changes from HEAD into your local branch 

Branches for adjustments for other organisations

benefit: you can make modifications to the UINavigation and the base data structure etc. and even to the screen en.yml files

I have this setup for one organisation:

  • created on my own server a git repository with an anonymous clone from the sourceforge openpetraorg git repository.
  • cloned my own repository to my workstation
  • create a branch on the repository, switch to the branch, modify a file, commit changes locally, push it not to master, but enter the name of your branch
  • you can pull on your server from the sf repository, to follow the changes in the main repository, and merge from master into your branch
  • you should create patches of your own development and post them in the OpenPetra forum so that all other users can benefit from your improvements

line feed issues

TortoiseGit

This works fine on Windows, although it is still work in progress...

It requires "Git on Windows" http://code.google.com/p/msysgit/; be careful: use the official git installer from that site, eg. Git-1.6.3.2-preview20090608.exe, not the fullinstaller or other packages.

Git Bash

  • You need to add each changed file before you commit. Otherwise that file will not be part of the next commit.
  • If you added too many files by accident, and you want to lose them completely: (use this carefully with -f) git rm . -r
    • even better: to unstage: git reset HEAD <file>...
  • undo all local changes: git checkout -f
  • to revert a single file: use git checkout filename (see http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file)
  • to ignore eg. *.bak files, create a file .gitignore and add the files; eg see OpenPetra/csharp/.gitignore