You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/git-help.md
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,3 +42,32 @@ git push -f
42
42
-`-f` or `--force`: This option forces Git to push the amended commit to the remote repository, rewriting history.
43
43
44
44
> Note: Force pushing can overwrite changes in the remote repository, so use it carefully, especially when working in a shared environment.
45
+
46
+
### 4. Moving Unpushed Commits Between Branches
47
+
48
+
If you need to move an unpushed commit from one branch to another, you can use git cherry-pick. Here's an example of moving a commit from branch `UAT-69` to branch `1629`:
49
+
50
+
1. First, identify the unpushed commit on the source branch:
51
+
```shell
52
+
git log UAT-69 --not --remotes --oneline
53
+
```
54
+
55
+
2. Note the commit hash from the output (e.g., `4cff367`)
56
+
57
+
3. Switch to the target branch and stash any current changes:
58
+
```shell
59
+
git checkout 1629
60
+
git stash # if you have uncommitted changes
61
+
```
62
+
63
+
4. Cherry-pick the commit:
64
+
```shell
65
+
git cherry-pick 4cff367
66
+
```
67
+
68
+
5. Restore your stashed changes if any:
69
+
```shell
70
+
git stash pop
71
+
```
72
+
73
+
> Note: The cherry-pick command creates a new commit on the target branch with the same changes but a different commit hash.
0 commit comments