$ git add --patch <filename> #(or -p for short),
-
-
Save loru88/df9226dae16d8ab3321556a948942f22 to your computer and use it in GitHub Desktop.
a series of handy git command I use often |
Performing a git merge with no commit or no fast-forward will merge the two code bases together. This will allow you to examine, test, and undo the merge if required.
$ git merge --no-commit --no-ff <branch-name>
If you need to undo the commit you can use:
$ git merge --abort
This will return git to its state before the merge occurred.
-
Use
git rebase -i HEAD~10
(or whatever you need to see far enough back). -
Mark the commit in question (a0865...) for edit by changing the word
pick
at the start of the line intoedit
. Don't delete the other lines as that would delete the commits -
Save the rebase file, and git will drop back to the shell and wait for you to fix that commit.
4a. to edit a pre existing commit
- Add your file with
git add
- Amend the commit with
git commit --amend
4b. to split an older commit
-
git reset HEAD~
to delete the last commit and restore files in the index. -
git add
andgit commit
the files you want in as many commit as you need. -
Do a
git rebase --continue
which will rewrite the rest of your commits against the new one. Follow steps 2 to 6 if you have marked more than one commit for edit.