Git create new branch in new folder
up vote
0
down vote
favorite
I know how to create branches in git bash with
git branch develop
then to switch to that branch
git checkout develop
I want this specific branch to have it's own folder and anytime i commit to this branch the folder is updated.
How do i accomplish this in Git bash?
git
add a comment |
up vote
0
down vote
favorite
I know how to create branches in git bash with
git branch develop
then to switch to that branch
git checkout develop
I want this specific branch to have it's own folder and anytime i commit to this branch the folder is updated.
How do i accomplish this in Git bash?
git
have separate repos ...
– treyBake
Nov 9 at 11:26
3
That's not really the idea of GIT. You have always checked out one branch and can commit to that. If you want to change branches, you have to checkout the new one.
– Lennart Blom
Nov 9 at 11:27
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I know how to create branches in git bash with
git branch develop
then to switch to that branch
git checkout develop
I want this specific branch to have it's own folder and anytime i commit to this branch the folder is updated.
How do i accomplish this in Git bash?
git
I know how to create branches in git bash with
git branch develop
then to switch to that branch
git checkout develop
I want this specific branch to have it's own folder and anytime i commit to this branch the folder is updated.
How do i accomplish this in Git bash?
git
git
asked Nov 9 at 11:23
user892134
1,10653578
1,10653578
have separate repos ...
– treyBake
Nov 9 at 11:26
3
That's not really the idea of GIT. You have always checked out one branch and can commit to that. If you want to change branches, you have to checkout the new one.
– Lennart Blom
Nov 9 at 11:27
add a comment |
have separate repos ...
– treyBake
Nov 9 at 11:26
3
That's not really the idea of GIT. You have always checked out one branch and can commit to that. If you want to change branches, you have to checkout the new one.
– Lennart Blom
Nov 9 at 11:27
have separate repos ...
– treyBake
Nov 9 at 11:26
have separate repos ...
– treyBake
Nov 9 at 11:26
3
3
That's not really the idea of GIT. You have always checked out one branch and can commit to that. If you want to change branches, you have to checkout the new one.
– Lennart Blom
Nov 9 at 11:27
That's not really the idea of GIT. You have always checked out one branch and can commit to that. If you want to change branches, you have to checkout the new one.
– Lennart Blom
Nov 9 at 11:27
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
The closest thing you can get is called "worktrees", you can read more about it here.
A short description of it is that you will have 1 main repository with a working folder, and you may for instance check out the master branch in this working folder.
Then additionally you would check out another branch, such as develop, into a separate working folder backed by the same repository.
This would allow you to have more than one branch "live" in a working folder on disk at the same time.
However, there is no "when I commit to this branch the folder is updated", instead you have to work in that folder.
It will basically look like two distinct clones, except that you don't have to push and pull between them since there is only one repository backing the two folders.
Here's a short example of how to set it up (using Windows command syntax):
C:> cd devprojects
C:devprojects> md MyAwesomeProject
C:devprojects> cd MyAwesomeProject
C:devprojectsMyAwesomeProject> git clone https://github.com/user/awesome.git master
.... snip
C:devprojectsMyAwesomeProject> cd master
C:devprojectsMyAwesomeProjectmaster> git worktree add ..develop develop
Preparing worktree (checking out 'develop')
HEAD is now at fca4b6c My most recent awesome commit
C:devprojectsMyAwesomeProjectmaster> cd ..
C:devprojectsMyAwesomeProject> dir
Volume in drive C is System
Volume Serial Number is 1234-5678
Directory of C:devprojectsMyAwesomeProject
02.10.2018 13.43 <DIR> .
02.10.2018 13.43 <DIR> ..
09.11.2018 10.26 <DIR> develop
08.11.2018 09.48 <DIR> master
0 File(s) 0 bytes
4 Dir(s) 229 636 960 256 bytes free
If you want to work in the develop
branch, do it in the develop
folder, and if you want to work on master
, do it in that folder.
After you have committed in one folder you can switch to the other and merge the other branch in, because it is just 1 repository backing both worktrees.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
The closest thing you can get is called "worktrees", you can read more about it here.
A short description of it is that you will have 1 main repository with a working folder, and you may for instance check out the master branch in this working folder.
Then additionally you would check out another branch, such as develop, into a separate working folder backed by the same repository.
This would allow you to have more than one branch "live" in a working folder on disk at the same time.
However, there is no "when I commit to this branch the folder is updated", instead you have to work in that folder.
It will basically look like two distinct clones, except that you don't have to push and pull between them since there is only one repository backing the two folders.
Here's a short example of how to set it up (using Windows command syntax):
C:> cd devprojects
C:devprojects> md MyAwesomeProject
C:devprojects> cd MyAwesomeProject
C:devprojectsMyAwesomeProject> git clone https://github.com/user/awesome.git master
.... snip
C:devprojectsMyAwesomeProject> cd master
C:devprojectsMyAwesomeProjectmaster> git worktree add ..develop develop
Preparing worktree (checking out 'develop')
HEAD is now at fca4b6c My most recent awesome commit
C:devprojectsMyAwesomeProjectmaster> cd ..
C:devprojectsMyAwesomeProject> dir
Volume in drive C is System
Volume Serial Number is 1234-5678
Directory of C:devprojectsMyAwesomeProject
02.10.2018 13.43 <DIR> .
02.10.2018 13.43 <DIR> ..
09.11.2018 10.26 <DIR> develop
08.11.2018 09.48 <DIR> master
0 File(s) 0 bytes
4 Dir(s) 229 636 960 256 bytes free
If you want to work in the develop
branch, do it in the develop
folder, and if you want to work on master
, do it in that folder.
After you have committed in one folder you can switch to the other and merge the other branch in, because it is just 1 repository backing both worktrees.
add a comment |
up vote
4
down vote
The closest thing you can get is called "worktrees", you can read more about it here.
A short description of it is that you will have 1 main repository with a working folder, and you may for instance check out the master branch in this working folder.
Then additionally you would check out another branch, such as develop, into a separate working folder backed by the same repository.
This would allow you to have more than one branch "live" in a working folder on disk at the same time.
However, there is no "when I commit to this branch the folder is updated", instead you have to work in that folder.
It will basically look like two distinct clones, except that you don't have to push and pull between them since there is only one repository backing the two folders.
Here's a short example of how to set it up (using Windows command syntax):
C:> cd devprojects
C:devprojects> md MyAwesomeProject
C:devprojects> cd MyAwesomeProject
C:devprojectsMyAwesomeProject> git clone https://github.com/user/awesome.git master
.... snip
C:devprojectsMyAwesomeProject> cd master
C:devprojectsMyAwesomeProjectmaster> git worktree add ..develop develop
Preparing worktree (checking out 'develop')
HEAD is now at fca4b6c My most recent awesome commit
C:devprojectsMyAwesomeProjectmaster> cd ..
C:devprojectsMyAwesomeProject> dir
Volume in drive C is System
Volume Serial Number is 1234-5678
Directory of C:devprojectsMyAwesomeProject
02.10.2018 13.43 <DIR> .
02.10.2018 13.43 <DIR> ..
09.11.2018 10.26 <DIR> develop
08.11.2018 09.48 <DIR> master
0 File(s) 0 bytes
4 Dir(s) 229 636 960 256 bytes free
If you want to work in the develop
branch, do it in the develop
folder, and if you want to work on master
, do it in that folder.
After you have committed in one folder you can switch to the other and merge the other branch in, because it is just 1 repository backing both worktrees.
add a comment |
up vote
4
down vote
up vote
4
down vote
The closest thing you can get is called "worktrees", you can read more about it here.
A short description of it is that you will have 1 main repository with a working folder, and you may for instance check out the master branch in this working folder.
Then additionally you would check out another branch, such as develop, into a separate working folder backed by the same repository.
This would allow you to have more than one branch "live" in a working folder on disk at the same time.
However, there is no "when I commit to this branch the folder is updated", instead you have to work in that folder.
It will basically look like two distinct clones, except that you don't have to push and pull between them since there is only one repository backing the two folders.
Here's a short example of how to set it up (using Windows command syntax):
C:> cd devprojects
C:devprojects> md MyAwesomeProject
C:devprojects> cd MyAwesomeProject
C:devprojectsMyAwesomeProject> git clone https://github.com/user/awesome.git master
.... snip
C:devprojectsMyAwesomeProject> cd master
C:devprojectsMyAwesomeProjectmaster> git worktree add ..develop develop
Preparing worktree (checking out 'develop')
HEAD is now at fca4b6c My most recent awesome commit
C:devprojectsMyAwesomeProjectmaster> cd ..
C:devprojectsMyAwesomeProject> dir
Volume in drive C is System
Volume Serial Number is 1234-5678
Directory of C:devprojectsMyAwesomeProject
02.10.2018 13.43 <DIR> .
02.10.2018 13.43 <DIR> ..
09.11.2018 10.26 <DIR> develop
08.11.2018 09.48 <DIR> master
0 File(s) 0 bytes
4 Dir(s) 229 636 960 256 bytes free
If you want to work in the develop
branch, do it in the develop
folder, and if you want to work on master
, do it in that folder.
After you have committed in one folder you can switch to the other and merge the other branch in, because it is just 1 repository backing both worktrees.
The closest thing you can get is called "worktrees", you can read more about it here.
A short description of it is that you will have 1 main repository with a working folder, and you may for instance check out the master branch in this working folder.
Then additionally you would check out another branch, such as develop, into a separate working folder backed by the same repository.
This would allow you to have more than one branch "live" in a working folder on disk at the same time.
However, there is no "when I commit to this branch the folder is updated", instead you have to work in that folder.
It will basically look like two distinct clones, except that you don't have to push and pull between them since there is only one repository backing the two folders.
Here's a short example of how to set it up (using Windows command syntax):
C:> cd devprojects
C:devprojects> md MyAwesomeProject
C:devprojects> cd MyAwesomeProject
C:devprojectsMyAwesomeProject> git clone https://github.com/user/awesome.git master
.... snip
C:devprojectsMyAwesomeProject> cd master
C:devprojectsMyAwesomeProjectmaster> git worktree add ..develop develop
Preparing worktree (checking out 'develop')
HEAD is now at fca4b6c My most recent awesome commit
C:devprojectsMyAwesomeProjectmaster> cd ..
C:devprojectsMyAwesomeProject> dir
Volume in drive C is System
Volume Serial Number is 1234-5678
Directory of C:devprojectsMyAwesomeProject
02.10.2018 13.43 <DIR> .
02.10.2018 13.43 <DIR> ..
09.11.2018 10.26 <DIR> develop
08.11.2018 09.48 <DIR> master
0 File(s) 0 bytes
4 Dir(s) 229 636 960 256 bytes free
If you want to work in the develop
branch, do it in the develop
folder, and if you want to work on master
, do it in that folder.
After you have committed in one folder you can switch to the other and merge the other branch in, because it is just 1 repository backing both worktrees.
answered Nov 9 at 11:45
Lasse Vågsæther Karlsen
286k82519716
286k82519716
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224808%2fgit-create-new-branch-in-new-folder%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
have separate repos ...
– treyBake
Nov 9 at 11:26
3
That's not really the idea of GIT. You have always checked out one branch and can commit to that. If you want to change branches, you have to checkout the new one.
– Lennart Blom
Nov 9 at 11:27