Archive

Archive for May, 2009

Git merging

May 4th, 2009 2 comments

OK, so maybe you can see a bit of a pattern here. I’ve been messing with git trying to get to the point where I can do what I want with it. Now that I understand how the branching functions, the next step was figuring out how to merge.

First thing to note is that this is how you can see the file differences in the two branches:
git diff ––name–status master..branch
Other views of the data:
git diff master..branch
git log master..branch
git shortlog master..branch

So that covers what the differences are between the branches before merging. Then there’s the real merging.
git merge branch ––no–commit

Then you can look at the changes with:
git status
git diff

If you see any problems you can turn back the clock with this:
git reset ––hard

Categories: git Tags:

Git branching warning

May 4th, 2009 No comments

When branching in git it is important to understand the meaning of branches. Branching needs to have state, so if any files are not commited, switching contexts between branches does not make sense. If you want to switch branches you should first commit the changes you’ve made to the branch OR stash your changes with the git stash command.

I’m still getting used to git, and what I was doing was modifying the same file in two different branches. I was constantly switching contexts through git checkout and everything was getting very confusing.

So just make sure that when switching contexts between branches that you either commit your changes to the branch you’re switching from or stashing away those changes.

Categories: git Tags:

Transfer SVN “Branch” into git branch

May 4th, 2009 No comments

There are easier ways to do this, but if you cannot use git-svn for whatever reason you can follow these directions.

  1. Start at the trunk level of your svn checkout and initialize git:
    git init
  2. Then exclude the subversion folders, by adding the following line to “.git/info/exclude”:
    .svn
    *.pyc
  3. Commit all the code:
    git add .
    git commit -m "Initial import of trunk"
  4. Create branch and move into branch:
    git checkout -b svn_branch
  5. Now merge the subversion changes into this git branch (check out this short post). So what’s actually happening is since your in the git “svn_branch” checkout it will add all your merge changes to that git branch.
    svn merge -r <branch copy rev>:HEAD http://<repo_url>/branches/<name of branch>
  6. At this point check to see if subversion did any merges. Add and commit the changes to the git branch:
    git add .
    git commit -a -m "Import of svn branch"
Categories: git Tags:

SVN status on branch

May 4th, 2009 No comments

I was trying to figure out what had changed since I branched. You can diff changes between versions, but you cannot run status on the difference between changes.

A simple workaround to get something that works like status is to run diff and then just print out those lines that start with “Index”. You need two things to do this:

1) The branch revision number: You need the revision number of the revision that created the branch. You can find this by using “svn log –stop-on-copy” from within the branch.
2) The URL of the branch. If you run “svn info” on the branch you can get this address.

svn diff -r <branch num>:HEAD http://<repo_url>/branches/<name of branch> | grep "^Index"


By the way, the most natural way to do this within subversion, is to first merge and then run status. Run the following code from within trunk:
svn merge -r <branch num>:HEAD http://<repo_url>/branches/<name of branch>"
svn st

Which is a bit much if you don’t want to merge yet.

Categories: Subversion Tags: