call python code of different git branch other than the current repository without switching branch
<p>So, basically I have 2 versions of a project and for some users, I want to use the latest version while for others, I want to use older version. Both of them have same file names and multiple users will use it simultaneously. To accomplish this, I want to call function from different git branch without actually switching the branch.
Is there a way to do so?</p>

<p>for eg., when my current branch is <code>v1</code> and the other branch is <code>v2</code>; depending on the value of variable <code>flag</code>, call the function</p>

<pre><code>if flag == 1:
    # import function f1() from branch v2
    return f1()
else:
    # use current branch v1
</code></pre>

<p>Without commenting on <em>why</em> you need to do that, you can simply checkout your repo twice: once for branch1, and one for branch2 (without cloning twice).<br>
See "<a href="http://stackoverflow.com/a/30186843/6309">git working on two branches simultaneously</a>".</p>

<p>You can then make your script aware of its current path (<code>/path/to/branch1</code>), and relative path to the other branch (<code>../branch2/...</code>)</p>

python git gitpython