Notes about Git: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
Line 6: Line 6:
** in my own words: working with branches is central to git; some people make a branch for each feature they are working on; I think each developer should have his own branch (or even several if working on different OS or machines), and merge to master as often as possible; you can have local and remote branches; it would make sense to create a local branch, and then push it to the server creating a remote branch.
** in my own words: working with branches is central to git; some people make a branch for each feature they are working on; I think each developer should have his own branch (or even several if working on different OS or machines), and merge to master as often as possible; you can have local and remote branches; it would make sense to create a local branch, and then push it to the server creating a remote branch.
** http://sites.google.com/a/insoshi.com/insoshi-guides/Git-Guides/working-on-a-local-development-branch
** http://sites.google.com/a/insoshi.com/insoshi-guides/Git-Guides/working-on-a-local-development-branch
** http://sites.google.com/a/insoshi.com/insoshi-guides/Git-Guides/pushing-up-your-changes
** http://blog.hasmanythrough.com/2008/12/18/agile-git-and-the-story-branch-pattern
** http://blog.hasmanythrough.com/2008/12/18/agile-git-and-the-story-branch-pattern
** http://sites.google.com/a/insoshi.com/insoshi-guides/Git-Guides/merge-vs-rebase
** http://sites.google.com/a/insoshi.com/insoshi-guides/Git-Guides/merge-vs-rebase
# 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


* line feed issues:
* line feed issues:

Revision as of 12:21, 1 September 2009

Manuals

# 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


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