Answer the question
In order to leave comments, you need to log in
Git how to keep two branches in a working copy at the same time?
There is a project (firmware for the microcontroller). I want to make a stripped-down version for testing purposes, which would be based on the code of the main version.
I want both versions to be in the working copy at the same time and there was no need to constantly switch. At the same time, it should be possible to easily add changes from the main version.
If the test version is made a separate branch, then, as far as I understand, it will not be possible to keep it in the working copy at the same time as master, unlike SVN, for example. You have to constantly switch between branches.
How can this be done in Git?
Answer the question
In order to leave comments, you need to log in
I see two options:
You simply clone the repository to another location and work with it separately.
- The entire repository is duplicated, but if it is not very large in size - there is nothing to worry about
- It will be necessary to transfer changes between repositories via pull / push, just commits will not be enough. For example, in the repository (a) a commit is made to the branch (1), in the repository (b) a fetch is made from the repository (a) of the branch (1) and then its commits can already be cherry-picked or somehow transferred to the branch (2 ).
The new version of git 2.5 has a command to create an additional working directory: git worktree. If it is possible to update git, this is the most convenient option. It should be borne in mind that the feature is still experimental.
No way, such a problem is not solved by git, but for example by configuration files. Roughly speaking, somewhere in the project there should be a file describing how the project should be built:
releaseConfig{
useMockObjects = false
ignoreNetwork = false
}
debugConfig{
useMockObjects = true
ignoreNetwork = true
}
In general, Git is good for source codes. Keeping binary firmware releases in a repository is not good.
Ideally, for testing, you need to have a subfolder in the master branch with scripts (scripts) for testing.
If we are talking about, say, experimental firmware, then it might make sense to create a separate git repository and periodically (after testing) pour it into a stable repository.
Or, alternatively, in order not to switch constantly, I suggest doing the following:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question