How do I commit my saved files on GitHub to a different branch?How to remove local (untracked) files from the current Git working tree?Undoing a git rebaseHow to modify existing, unpushed commits?How to undo 'git add' before commit?How do I undo the most recent commits in Git?Find and restore a deleted file in a Git repositoryHow do you create a remote Git branch?How do I delete a Git branch locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?
Why was the small council so happy for Tyrion to become the Master of Coin?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Why not use SQL instead of GraphQL?
Dragon forelimb placement
Why don't electron-positron collisions release infinite energy?
Do VLANs within a subnet need to have their own subnet for router on a stick?
How old can references or sources in a thesis be?
LaTeX closing $ signs makes cursor jump
How do I create uniquely male characters?
Is it unprofessional to ask if a job posting on GlassDoor is real?
Why are electrically insulating heatsinks so rare? Is it just cost?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
Why Is Death Allowed In the Matrix?
What is the word for reserving something for yourself before others do?
Is this a crack on the carbon frame?
Did Shadowfax go to Valinor?
How does one intimidate enemies without having the capacity for violence?
Arthur Somervell: 1000 Exercises - Meaning of this notation
Do I have a twin with permutated remainders?
Service Entrance Breakers Rain Shield
Is it important to consider tone, melody, and musical form while writing a song?
What do you call a Matrix-like slowdown and camera movement effect?
Python: next in for loop
Fencing style for blades that can attack from a distance
How do I commit my saved files on GitHub to a different branch?
How to remove local (untracked) files from the current Git working tree?Undoing a git rebaseHow to modify existing, unpushed commits?How to undo 'git add' before commit?How do I undo the most recent commits in Git?Find and restore a deleted file in a Git repositoryHow do you create a remote Git branch?How do I delete a Git branch locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Currently, the branch that I can commit saved files to is master
.
However, I want to commit my saved files to a different branch called "First-Level" (I'm designing a game). But I haven't managed to make it work for now.
It will only continue to commit to the master
branch and not the First-Level
branch. What should I do?
git branch commit
add a comment |
Currently, the branch that I can commit saved files to is master
.
However, I want to commit my saved files to a different branch called "First-Level" (I'm designing a game). But I haven't managed to make it work for now.
It will only continue to commit to the master
branch and not the First-Level
branch. What should I do?
git branch commit
Are you saving the files on github, or are you committing locally and pushing to github?
– Lasse Vågsæther Karlsen
Mar 22 at 7:40
add a comment |
Currently, the branch that I can commit saved files to is master
.
However, I want to commit my saved files to a different branch called "First-Level" (I'm designing a game). But I haven't managed to make it work for now.
It will only continue to commit to the master
branch and not the First-Level
branch. What should I do?
git branch commit
Currently, the branch that I can commit saved files to is master
.
However, I want to commit my saved files to a different branch called "First-Level" (I'm designing a game). But I haven't managed to make it work for now.
It will only continue to commit to the master
branch and not the First-Level
branch. What should I do?
git branch commit
git branch commit
edited Mar 22 at 11:47
RomainValeri
5,61121335
5,61121335
asked Mar 21 at 23:59
serendipity456serendipity456
91
91
Are you saving the files on github, or are you committing locally and pushing to github?
– Lasse Vågsæther Karlsen
Mar 22 at 7:40
add a comment |
Are you saving the files on github, or are you committing locally and pushing to github?
– Lasse Vågsæther Karlsen
Mar 22 at 7:40
Are you saving the files on github, or are you committing locally and pushing to github?
– Lasse Vågsæther Karlsen
Mar 22 at 7:40
Are you saving the files on github, or are you committing locally and pushing to github?
– Lasse Vågsæther Karlsen
Mar 22 at 7:40
add a comment |
3 Answers
3
active
oldest
votes
If you already have a new branch created, directly use
git checkout branchname
Else, to move to another branch, use
git checkout -b branchname
To check the branches, use git branch
add a comment |
I always use Git Extension with some awesome Git features we can see in friendly GUI. You can create new branch in your local repository, then you can push your branch. Once a new branch is created, then you can choose the branch and start do anything in that branch (commit, pull, push). Hope it helps!
add a comment |
To commit on another branch
Whether or not you already commited on the master
branch, just create now a new branch and commit there :
# quite litteraly "checkout a new branch called First-Level"
git checkout -b First-Level
# at previous step, as Arjun rightfully point out, omit -b if the branch exists
# add every change and commit (omit the "a" if you already staged specific changes)
git commit -am "Modified stuff in order to achieve a goal"
(...........if you never commited to your local master
, you're good here :-)
To fix unwanted commits on master
After having commited on the new branch like we saw above, check your local history with git log
to locate the commits to "erase" from master. No worries though, they'll be safe on your First-Level
branch.
(If you know you have only to go back a few commits, no need to let git output a long unneeded history, cut it short with -n
, for n
commits back)
I'll assume the following output with -3
, but adapt to your case of course :
commit 287a91bd66781331c996067bd09521ea0880be5f (HEAD -> First-Level, master)
Author: serendipity456 <someone@somewh.ere>
Date: Wed Feb 27 02:07:10 2019 +0100
Modified stuff in order to achieve a goal
commit 982ee15f5ec26818f9a563c3c7dd52041258669d
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Changed a bunch of things in places
commit d9ad330f8acaaf4fdc0785b699efe2aa527507fe (HEAD -> origin/master)
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Solid foundations for the game
If at this point you identify let's say the last commit, d9ad330
(where the remote* still points to) to be the one you want master to stay at, proceed as following :
git checkout master
git reset --hard d9ad330
* (here in my example, but you didn't mention if you used one)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f55290949%2fhow-do-i-commit-my-saved-files-on-github-to-a-different-branch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you already have a new branch created, directly use
git checkout branchname
Else, to move to another branch, use
git checkout -b branchname
To check the branches, use git branch
add a comment |
If you already have a new branch created, directly use
git checkout branchname
Else, to move to another branch, use
git checkout -b branchname
To check the branches, use git branch
add a comment |
If you already have a new branch created, directly use
git checkout branchname
Else, to move to another branch, use
git checkout -b branchname
To check the branches, use git branch
If you already have a new branch created, directly use
git checkout branchname
Else, to move to another branch, use
git checkout -b branchname
To check the branches, use git branch
edited Mar 22 at 9:02
Pranav Totla
7291623
7291623
answered Mar 22 at 7:35


Arjun GuptaArjun Gupta
11
11
add a comment |
add a comment |
I always use Git Extension with some awesome Git features we can see in friendly GUI. You can create new branch in your local repository, then you can push your branch. Once a new branch is created, then you can choose the branch and start do anything in that branch (commit, pull, push). Hope it helps!
add a comment |
I always use Git Extension with some awesome Git features we can see in friendly GUI. You can create new branch in your local repository, then you can push your branch. Once a new branch is created, then you can choose the branch and start do anything in that branch (commit, pull, push). Hope it helps!
add a comment |
I always use Git Extension with some awesome Git features we can see in friendly GUI. You can create new branch in your local repository, then you can push your branch. Once a new branch is created, then you can choose the branch and start do anything in that branch (commit, pull, push). Hope it helps!
I always use Git Extension with some awesome Git features we can see in friendly GUI. You can create new branch in your local repository, then you can push your branch. Once a new branch is created, then you can choose the branch and start do anything in that branch (commit, pull, push). Hope it helps!
answered Mar 22 at 9:07
Nov AckermanNov Ackerman
1
1
add a comment |
add a comment |
To commit on another branch
Whether or not you already commited on the master
branch, just create now a new branch and commit there :
# quite litteraly "checkout a new branch called First-Level"
git checkout -b First-Level
# at previous step, as Arjun rightfully point out, omit -b if the branch exists
# add every change and commit (omit the "a" if you already staged specific changes)
git commit -am "Modified stuff in order to achieve a goal"
(...........if you never commited to your local master
, you're good here :-)
To fix unwanted commits on master
After having commited on the new branch like we saw above, check your local history with git log
to locate the commits to "erase" from master. No worries though, they'll be safe on your First-Level
branch.
(If you know you have only to go back a few commits, no need to let git output a long unneeded history, cut it short with -n
, for n
commits back)
I'll assume the following output with -3
, but adapt to your case of course :
commit 287a91bd66781331c996067bd09521ea0880be5f (HEAD -> First-Level, master)
Author: serendipity456 <someone@somewh.ere>
Date: Wed Feb 27 02:07:10 2019 +0100
Modified stuff in order to achieve a goal
commit 982ee15f5ec26818f9a563c3c7dd52041258669d
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Changed a bunch of things in places
commit d9ad330f8acaaf4fdc0785b699efe2aa527507fe (HEAD -> origin/master)
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Solid foundations for the game
If at this point you identify let's say the last commit, d9ad330
(where the remote* still points to) to be the one you want master to stay at, proceed as following :
git checkout master
git reset --hard d9ad330
* (here in my example, but you didn't mention if you used one)
add a comment |
To commit on another branch
Whether or not you already commited on the master
branch, just create now a new branch and commit there :
# quite litteraly "checkout a new branch called First-Level"
git checkout -b First-Level
# at previous step, as Arjun rightfully point out, omit -b if the branch exists
# add every change and commit (omit the "a" if you already staged specific changes)
git commit -am "Modified stuff in order to achieve a goal"
(...........if you never commited to your local master
, you're good here :-)
To fix unwanted commits on master
After having commited on the new branch like we saw above, check your local history with git log
to locate the commits to "erase" from master. No worries though, they'll be safe on your First-Level
branch.
(If you know you have only to go back a few commits, no need to let git output a long unneeded history, cut it short with -n
, for n
commits back)
I'll assume the following output with -3
, but adapt to your case of course :
commit 287a91bd66781331c996067bd09521ea0880be5f (HEAD -> First-Level, master)
Author: serendipity456 <someone@somewh.ere>
Date: Wed Feb 27 02:07:10 2019 +0100
Modified stuff in order to achieve a goal
commit 982ee15f5ec26818f9a563c3c7dd52041258669d
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Changed a bunch of things in places
commit d9ad330f8acaaf4fdc0785b699efe2aa527507fe (HEAD -> origin/master)
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Solid foundations for the game
If at this point you identify let's say the last commit, d9ad330
(where the remote* still points to) to be the one you want master to stay at, proceed as following :
git checkout master
git reset --hard d9ad330
* (here in my example, but you didn't mention if you used one)
add a comment |
To commit on another branch
Whether or not you already commited on the master
branch, just create now a new branch and commit there :
# quite litteraly "checkout a new branch called First-Level"
git checkout -b First-Level
# at previous step, as Arjun rightfully point out, omit -b if the branch exists
# add every change and commit (omit the "a" if you already staged specific changes)
git commit -am "Modified stuff in order to achieve a goal"
(...........if you never commited to your local master
, you're good here :-)
To fix unwanted commits on master
After having commited on the new branch like we saw above, check your local history with git log
to locate the commits to "erase" from master. No worries though, they'll be safe on your First-Level
branch.
(If you know you have only to go back a few commits, no need to let git output a long unneeded history, cut it short with -n
, for n
commits back)
I'll assume the following output with -3
, but adapt to your case of course :
commit 287a91bd66781331c996067bd09521ea0880be5f (HEAD -> First-Level, master)
Author: serendipity456 <someone@somewh.ere>
Date: Wed Feb 27 02:07:10 2019 +0100
Modified stuff in order to achieve a goal
commit 982ee15f5ec26818f9a563c3c7dd52041258669d
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Changed a bunch of things in places
commit d9ad330f8acaaf4fdc0785b699efe2aa527507fe (HEAD -> origin/master)
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Solid foundations for the game
If at this point you identify let's say the last commit, d9ad330
(where the remote* still points to) to be the one you want master to stay at, proceed as following :
git checkout master
git reset --hard d9ad330
* (here in my example, but you didn't mention if you used one)
To commit on another branch
Whether or not you already commited on the master
branch, just create now a new branch and commit there :
# quite litteraly "checkout a new branch called First-Level"
git checkout -b First-Level
# at previous step, as Arjun rightfully point out, omit -b if the branch exists
# add every change and commit (omit the "a" if you already staged specific changes)
git commit -am "Modified stuff in order to achieve a goal"
(...........if you never commited to your local master
, you're good here :-)
To fix unwanted commits on master
After having commited on the new branch like we saw above, check your local history with git log
to locate the commits to "erase" from master. No worries though, they'll be safe on your First-Level
branch.
(If you know you have only to go back a few commits, no need to let git output a long unneeded history, cut it short with -n
, for n
commits back)
I'll assume the following output with -3
, but adapt to your case of course :
commit 287a91bd66781331c996067bd09521ea0880be5f (HEAD -> First-Level, master)
Author: serendipity456 <someone@somewh.ere>
Date: Wed Feb 27 02:07:10 2019 +0100
Modified stuff in order to achieve a goal
commit 982ee15f5ec26818f9a563c3c7dd52041258669d
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Changed a bunch of things in places
commit d9ad330f8acaaf4fdc0785b699efe2aa527507fe (HEAD -> origin/master)
Author: serendipity456 <someone@somewh.ere>
Date: Sat Feb 23 15:17:52 2019 +0100
Solid foundations for the game
If at this point you identify let's say the last commit, d9ad330
(where the remote* still points to) to be the one you want master to stay at, proceed as following :
git checkout master
git reset --hard d9ad330
* (here in my example, but you didn't mention if you used one)
edited Mar 23 at 17:05
answered Mar 22 at 0:01
RomainValeriRomainValeri
5,61121335
5,61121335
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.
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%2f55290949%2fhow-do-i-commit-my-saved-files-on-github-to-a-different-branch%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
Are you saving the files on github, or are you committing locally and pushing to github?
– Lasse Vågsæther Karlsen
Mar 22 at 7:40