Reputation: 740
I was working on an app and when I pulled new code today morning, I found that the app was not working, so, I did a git checkout
to go to a previous commit.
Now I have made some changes to this commit and I want to create a new commit with these changes.
Is this possible? If not, please suggest a way to achieve the objective.
Upvotes: 1
Views: 1680
Reputation: 637
Yes, this is very possible.
git checkout branch_Id // previous commit
git checkout -b new branch name // Create branch at current position
git add .//make change and add
git commit -m 'your commit statement'
git checkout master
git merge new branch name
Upvotes: 1
Reputation: 60235
Just git checkout master; git commit
. Changes in your index and worktree stay there until you commit them. If there are conflicting changes between your work and the new checkout, git checkout -m master
and resolve the conflicts, then git commit
.
Upvotes: 1
Reputation: 141544
Assuming you have previously done git checkout abcdef
and made changes; now you do:
git checkout -b foo
which will not make any changes to source files, it just creates a new branch name foo
.
Then you do the usual git add
and git commit
commands that you would do to commit changes.
Upvotes: 1
Reputation: 183
Assuming your branch is master
git checkout f95ecfe // previous commit
git checkout -b bug_fix // Create branch at current possition
git add -A //make change and add
git commit -m 'commit message'
git checkout master
git merge bug_fix
Hope this helps
Upvotes: 4