Help with local build and git

For some time now I’ve been building and flashing locally.

Occasionally I run…

git fetch

… in the 3 repositories (core-common-lib, core-communication-lib and core-firmware) to ensure I’ve got the latest versions of everything (or I at least thought that was what I should be doing), but this seems to becoming more unstable recently.

I’m no git master (at all!) so I am now questioning whether I am doing things right / looking at the right (i.e. most stable) ‘branch’.

Is anyone good with git that could help me out?

I really want to know…

  • Which branch I’m currently looking at when I run git fetch? (master ?)
  • Which branch is the most stable? (origin/compile-server2 ?)
  • How should I switch branches, so that my local copy is the most/more stable?

I’m running Linux if that helps. Thanks guys!

Hi @binaryfrost,

I think you want to be doing a git merge master after you do a fetch, or just do a git pull. To see where you are, you can type git log after you do a pull to see what commits are included, and you can show branches and what branch you’re on with git branch, or switch to a branch with git checkout compile-server2 etc. :slight_smile: Hope that helps!

Thanks,
David

Errr… just did a git checkout compile-server2 and now I’ve lost all my changes to application.cpp, src/build.mk etc etc

Is there a non-destructive way of doing this locally, so that I can stay in-step with compile-server2, but still keep my application?

Hi @binaryfrost,

No worries, if you checked in your changes (which you must have before switching branches), then nothing is lost, you can just git checkout master to get back to the other branch, or you can merge specific commits over with a git merge <<commit-hash>>>

You can also do a fancy git thing by marking compile-server2 as an upstream repo --> checkout the ‘configuring remotes’ section here: https://help.github.com/articles/fork-a-repo

Thanks,
David

Thanks @Dave.

git branch now shows for each repo:

* compile-server2
  master

…which I guess is right.

I’ve gone with the git remote add upstream https://github.com/spark/core-xxx.git suggestion too.

So presumably I now only need to to run git fetch upstream in each directory periodically now?

I think with an upstream configuration, the workflow is closer to:

git fetch upstream
# Fetches any new changes from the original repository

git merge upstream/compile-server2
# Merges any changes fetched into your working files

EDIT: I removed a long speil here and replaced it with a better laid out post …

Working with Git and Local Project Branches.

Hope it helps.

1 Like