GIT clone branch to older commit in another directory
I have 2 directories of the same project, let call them directories A and B.
Now A stayed with the original code and fixed a few minor bugs, and commited the changes, so A git branch looks like this:
A: (original)-(bug fix 1) - (bug fix 2) - (bug fix 3)
While B, I decided to change the look of the application but I havent commited yet. so B git branch looks like this:
What I would like to do is merge these 2 git repos from the original clone so I can have the following:
A: (original)-(bug fix 1) - (bug fix 2) - (bug fix 3)--------(merge both) \ / branch B: \ -----------------(New version look) -------------
2 Solutions collect form web for “GIT clone branch to older commit in another directory”
If you can push back to that repo, but you don’t want to push
B, you can:
- go to your A local clone
add the B local clone as a remote:
git remote add repoB ../B
fetch and merge:
git fetch repoB git checkout A git merge repoB/B
Hello I have 2 directories of the same project, let call them directories A and B. These two folder were cloned from a master git repo in another location,
Instead of cloning the repositories use
Git worktree was introduced in 2007 under the
contrib folder in git repo and was called
new-workdir. In git v2.5 is was renamed to
The most simple syntax is this:
git worktree add <second path>/<branch name>
will create another folder on your computer which allow you to work on different branches simultaneously.
git worktree will create 2 separate working folders separated from each other while pointing to the same repository.
This will allow you do to any experimentals on the new worktree without having any effect on the repository itself. In the attached image you can see that there are 2 separate working folder but both of them are using a single repo and share the content.
Here is a sample on how to create new worktree and what is the result of it:
What I would like to do is merge these 2 git repos from the original clone so I can have the following…
Now since you are working on the same repository you can
cherry-pick without pulling or pushing to the remote since you dont need to use the remote.
its all local !!!