Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

Friday, February 10, 2012

GIT: Visualization


Tool for visualizing GIT/SVN/CVS Repositories:
http://code.google.com/p/gource/

Monday, February 6, 2012

GIT: DIFF working tree against some revision or branch

git diff  fw7e7f8wef8wef yourfile.c

 

Gives the changes between current working dir and revision  or branch: fw7e7f8wef8wef

Tuesday, January 31, 2012

GIT: Tag particular commit

Simply use git tag as usual but provide a valid commit hash:

 

git tag -a v1.0  cc622186a7322713f0ee4df8d58a1adcfe2ffef6   -m"tag a particular commit"

Friday, December 16, 2011

GIT: git show and git describe

You can easily have a look at a tag with

git show  mytag

Much more powerfull and showing you all sorts of realations between tags and commits is git describe:

http://gitfu.wordpress.com/2008/05/25/git-describe-great-another-way-to-refer-to-commits/

Tuesday, July 12, 2011

GIT: Compare/Diff working directory against server/repository state

git fetch --> updates your local rep but not your working Dir
git diff ... origin gives you the comparison

Monday, July 11, 2011

GIT: Ignore File mode/right changes

If you have files or directories under git control and change the rights of them, git does recognize them as changed.
To force git to ignore these changes just execute the following.

git config core.filemode false

You can reenable that after all files have a new revision because of an actual change and are comitted in the new mode anyway.

Monday, June 27, 2011

Tuesday, June 14, 2011

GIT: Getting information about tags

To show the tags you made and the comments or tag messages:

git tag -l -n1

Monday, March 28, 2011

Wednesday, March 16, 2011

GIT: Pushing a new repository to a git server the first time

Scenario:
You created some local repository and worked on that for a while. Now you want to have it on a server so that others can collaborate.
We want to keep the full history so we want to push the current repository to the server. In order to do this at least for the master branch you have to edit the config file at:
/.git/config
It probably looks like the following:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true



The easiest way to get everything right is to check out the empty repository from the server via git clone and diff the two config files.
Finally you see that you have to add something like:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = user@yourgitserver.com:MyNewProject
[branch "master"]
remote = origin
merge = refs/heads/master

To the existing config.

Now issue a git push origin master and the master will be pushed.
If you know whether that works with branches as well or how to get that working, please drop me a comment!?

There are other ways to just give the repository as a argument at the git push command but I like to keep my old directories.

Wednesday, January 26, 2011

GIT: Merging changes of a branch back to master

You branched out for development and now it is time to get the improvements back to the master branch.
This is achieve by git merge while on the master branch.

To be sure to not mess up anything, I prefer to clone my repository first and do the merge there.
So best is if you commit all changes in master and dev branch. Do a couple of pushs and pulls so everything is in sync and then clone your repository to a new location.
You can directly clone the branch you want to merge then proceed to 2. otherwise do a

  • git checkout branchname

  • git checkout master

  • git merge branchname


You have to resolve any conflicts in any files by removing the spiky brackets in the file and of course take a close look what caused the conflict and fix it.
Then add the file via git add and commit it via git commit .
Do this for every file.

Friday, January 14, 2011

GIT: Creating a local Repository

Till now all my posts concerned repositories already created. But how to create your own git rep in the first place?
Simply execute:


mkdir new-rep-dir
cd new-rep-dir
git init-db

and the new-rep-dir is a git repository

Hint by TZ: git init is the alias for git init-db

Thursday, December 23, 2010

GIT: Working on Branches: Sharing files and commits

Motivation:
You have several development branches but basically use the same files to test or benchmark all versions. Then there is no sense in developing different code in all these branches for the same purpose.
You can easily merge single files from one branch to the other by cherry-pick.

Example:
1. First commit a file and only the file you want to share, nothing else:
git commit bench.sh -m"Newest fancy script which does all tests for all versions"
2. Save the key somewhere.
3. Go to the other branch folder or checkout the other branch in the same folder, as you like.
4. git cherry-pick 123784hash

You should now have the same file in the other branch as well.


Thanks to Markus for pointing me towards this.

Wednesday, December 22, 2010

GIT: Tagging

Tags are nothing else then names for certain revision.
So called annotated tags store the status of the project at a specific point in time for future use.

Create a tag:
git tag -a v1.0 -m"Your comment for version 1.0"

Push tag to repository:
git push --tags

Wednesday, December 15, 2010

GIT: Branching

To create a branch for some development work in git is really easy.
First clone an existing repository like described here.

In the new directory simple execute: git branch newbranch.
However, if you execute git status you will see that you are still on the master branch or the other branch you worked before (then the question is how did you get there
??).
Execute git checkout newbranch an d git status will show you that you are now working on branch .
In order to push this information to another repository or a git server, git push per se will not do the trick. First you need to execute git push origin newbranch and now your branch is committed to the other repository.

Friday, November 5, 2010

GIT: Distributed Revision System

Distributed Revision Systems have the advantage that a central server is not necessary in contrast to CVS or SVN. Furthermore commits and even more important diffs to other versions can be made  with a local repository only. This is an adanvantage when working offline, e.g. on journeys, on a plane etc. Furthermore a new branch for testing can quickly be made by simply cloning the repository once more and work in the new directory.

To setup up git client on your ubuntu linux just type aptitude install git-core and you're done.

For windows you need to download 2 packages:

MSysGIT
Tortoise GIT

If you install in this order everything should be fine. If Tortoise later on complains about not finding git, you get to Tortoise' Settings and point the git path to the directory where you installed msysgit +\bin e.g. c:\Program Files\git\bin

Working together on a project can be done like CVS and SVN. But in contrast to these central methods, you do not commit your files to the central repository but first to your local rep.

The central repository is then updated by a so called push.

To get the updates from the central server you do a pull.

Basic tasks are:

  1. Clone the repository to your local workstation: git clone git@someserver.com:projectname

  2. Add new files: git add xyz

  3. Commit the new files or changes is already added files: git commit xyz

  4. Send changes to server: git push

  5. Get changes from server to rep only: git fetch

  6. Get changes from server to rep and update checked out files: git pull


This is just for starting with git, please consult the manuals and documentation on more advanced topics.
Thanks to Thomas for this information for a quick start.

Another Distributed Revision System is mercurial where you find a small tutorial here: MercurialHG

GIT: Distributed Revision System

Distributed Revision Systems have the advantage that a central server is not necessary in contrast to CVS or SVN. Furthermore commits and even more important diffs to other versions can be made  with a local repository only. This is an adanvantage when working offline, e.g. on journeys, on a plane etc. Furthermore a new branch for testing can quickly be made by simply cloning the repository once more and work in the new directory.

To setup up git client on your ubuntu linux just type aptitude install git-core and you're done.

For windows you need to download 2 packages:

MSysGIT
Tortoise GIT

If you install in this order everything should be fine. If Tortoise later on complains about not finding git, you get to Tortoise' Settings and point the git path to the directory where you installed msysgit +\bin e.g. c:\Program Files\git\bin

Working together on a project can be done like CVS and SVN. But in contrast to these central methods, you do not commit your files to the central repository but first to your local rep.

The central repository is then updated by a so called push.

To get the updates from the central server you do a pull.

Basic tasks are:

  1. Clone the repository to your local workstation: git clone git@someserver.com:projectname

  2. Add new files: git add xyz

  3. Commit the new files or changes is already added files: git commit xyz

  4. Send changes to server: git push

  5. Get changes from server to rep only: git fetch

  6. Get changes from server to rep and update checked out files: git pull


This is just for starting with git, please consult the manuals and documentation on more advanced topics.
Thanks to Thomas for this information for a quick start.

Another Distributed Revision System is mercurial where you find a small tutorial here: MercurialHG