[GRASS-dev] git: how to switch between branches?

Michael Barton Michael.Barton at asu.edu
Sun May 19 20:14:59 PDT 2019


Markus and others,

I've looked at this a little now, and here is a possible workflow. For Git sophisticates, I realize that this negates to some extent the lightweight flexibility of the Git approach to versioning. And of course, not everyone has to do this. But to create separate source distributions in different directories locally, so that devs who want to can continue with their current workflow (at least for awhile), you should be able to do the following (example from RB7.4)

CMB-MacBook-Pro:grass_source cmbarton$ mkdir releasebranch_7_4
CMB-MacBook-Pro:grass_source cmbarton$ cd releasebranch_7_4
CMB-MacBook-Pro:releasebranch_7_4 cmbarton$ git clone https://github.com/OSGeo/grass.git
Cloning into 'grass'...
remote: Enumerating objects: 131, done.
remote: Counting objects: 100% (131/131), done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 228899 (delta 31), reused 39 (delta 15), pack-reused 228768
Receiving objects: 100% (228899/228899), 232.04 MiB | 549.00 KiB/s, done.
Resolving deltas: 100% (169949/169949), done.
Checking out files: 100% (7355/7355), done.
CMB-MacBook-Pro:releasebranch_7_4 cmbarton$ cd grass
CMB-MacBook-Pro:grass cmbarton$ git checkout releasebranch_7_4
Branch 'releasebranch_7_4' set up to track remote branch 'releasebranch_7_4' from 'origin'.
Switched to a new branch 'releasebranch_7_4'

This will give you source files from RB7.4.

Note a couple of other alternatives:

1. You can just clone GRASS once and do a checkout to each branch you want to work on at any time. Git will then replace all files that differ in that branch from master. Not much in 7.6, many more in 7.2

2. You could have one master GRASS directory and one 'branch' directory in which you use checkout for each branch other than master you want to work in when you are in the branch directory.

Git is very flexible in this regard AFAICT. Most Git tutorials I've seen discuss method 1 above, with discussions of additional forks and merging of branches, assuming that the ultimate goal is to deploy all releases from the master branch. GRASS does not follow this kind of assumed 'normal' work flow. We are working on 2-3 different branch releases simultaneously.

Of course Git offers the opportunity to begin to rethink the overall GRASS workflow. But we might want to make these transitions in stages to keep everyone on board and limit confusion (e.g., get all up to speed on using Git commands to get the source code and commit revisions more or less the way we do now, and then work out new common workflows for doing these activities). Git's flexibility means that we can make these changes as incrementally or as quickly as works for the community.

Michael



____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Head, Graduate Faculty in Complex Adaptive Systems Science
Arizona State University

Currently Senior Research Fellow, Institute for Advanced Sustainability Studies
Potsdam, Deutchland

voice:  480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)
fax: 480-965-7671 (SHESC),  480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu















On May 20, 2019, at 3:00 AM, grass-dev-request at lists.osgeo.org<mailto:grass-dev-request at lists.osgeo.org> wrote:

Message: 2
Date: Sun, 19 May 2019 19:27:34 +0200
From: Markus Neteler <neteler at osgeo.org<mailto:neteler at osgeo.org>>
To: GRASS developers list <grass-dev at lists.osgeo.org<mailto:grass-dev at lists.osgeo.org>>
Subject: [GRASS-dev] git: how to switch between branches?
Message-ID:
<CALFmHhvwDZHOqU07Q8s12qN10qMmgQdAvVYdpjCRKTYxZhcPig at mail.gmail.com<mailto:CALFmHhvwDZHOqU07Q8s12qN10qMmgQdAvVYdpjCRKTYxZhcPig at mail.gmail.com>>
Content-Type: text/plain; charset="UTF-8"

Hi,

being a kind of git newbie, I'm struggly with switching between the
different release branches (and master).

Starting from a clean state (nothing downloaded yet), it this correct:

## 0. getting the code: fork in GH, then
# git clone git at github.com<mailto:git at github.com>:your_GH_account/grass.git
# git remote ...

Now I want the each release branch in a separate directory (!) as I
keep the compiled binaries and run GRASS directly from there.

# make a local copy of the freshly cloned source code (example: relbranch76(:
cp -rp grass grass76_branch
cd grass76_branch/

## 1. preparation: check if the local branch-copy of the remote branch exists
git branch -a

# if yes:
#   nothing to do, continue below
# if not:
#   create a new local branch that tracks a remote branch
git checkout --track upstream/releasebranch_7_6
## ?? or
##  git checkout --track remotes/upstream/releasebranch_7_6

# check
git branch -a

## 2. subsequently, switching between master and branch

# switch to branch, e.g.
git checkout upstream/releasebranch_7_6

# back to master
git checkout master

Please suggest, at non-git-expert level :-)

Markus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20190520/bb467bac/attachment-0001.html>


More information about the grass-dev mailing list