Code versioning strategy

5 posts / 0 new
Last post
Code versioning strategy

Has anyone got a good strategy for keeping your race code up to date. I want to keep my code and the race code (which I may edit) in a private repository of my own, but then how do I keep up to date with changes to the original code? Does this just have to be a manual process, or has anyone done something clever?


Geoff Riley
Geoff Riley's picture
Code versioning

I just created a local branch, called 'geoff' in mt case, on git:

$ git checkout -b geoff

Then do all my work on that branch, committing my changes to the branch:

$ git commit -a -m 'did some really cool edits'

but not pushing the branch to the server (the server would reject it anyway because we only have read access).

When an update to the main source is available, then I fetch the updates:

$ git fetch origin

and merge them into my working branch

$ git merge origin/master

These latter two steps can be combined in a single git pull origin, but it's easier to explain what is happening in two steps.

Hope that helps.


piborg's picture
Beat me to it :)

I was half-way through writing a long-winded explanation when I saw your reply.
As yours is easier to read I will admit surrender :)

One thing which is still worth adding is about merge conflicts.

Merge conflicts occur when a file has changed in both places in a way that Git cannot solve on its own.
For example if we have updated the autoGainMax setting and you have as well.

In this case Git does not know which value to use and you will see something like this:

$ git merge origin/master
CONFLICT (content): Merge conflict in
Automatic merge failed; fix conflicts and then commit the result.

Auto-merging is fine, it is just when you see the CONFLICT message that a problem needs to be fixed.

The conflicted file will now have some slightly odd lines, like this:

autoGainMax = 5.0
autoGainMax = 4.0
>>>>>>> origin/

In this case HEAD is your version, which are all the lines above the ======= mark.
All the lines below the ======= mark are origin/master, our updated version.

Change the file to be correct again by replacing all of the text including the <<<<<<< and >>>>>>> lines with what you want to keep.
Then commit the fix to finish the process:

git commit -a -m 'kept my autoGainMax'

There is a good reference (if a little dry) here: Basic Merge Conflicts.

Geoff Riley
Geoff Riley's picture

Hehe... I've told people about using git before and found that if you bring up conflict resolution straight away, then they spend forever worrying about how they'll cope with that rather than taking the plunge :)


Just what I was looking for -

Just what I was looking for - thanks guys!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.