Site icon JnPnote

[Learning Git] Moving Work Around

This is the personal study note for remembering and reviewing what I learned about Git.

Commands
git cherry-pick commit1 commit2 ……..: To copy a series of commits below current location. The command rebase is merging, but cherry-pick is copying. After cherry-pick is run, the current location(HEAD) is gonna be at the last commit that is copied. This command is useful to copy down the original branch to other branch. This command can copy any commits in the projects.
git rebase -i HEAD~4: branch_name can be used instead HEAD~4. To reorder or pick on or off the commits, and copy them to another branch up to 4 commits. It will be shown in the UI window. The current location is moved to the last commit copied. And the current branch is moved to the copied one. This command is useful to copy, reorder, and move the whole branch. This command can copy only the branch upwards. Then, what about the original branch? What is the branch name called then?
git rebase branch_name1 branch_name2: To move branch_name2 to branch_name1, and change the current HEAD as the branch_name2. To up-to-date the branch_name2. (under the branch_name1 put branch_name2)
git checkout HEAD~2^2^^: To move HEAD from the current HEAD to 2 upwards(~2), 1 upward to second parent(^2), 2 upwards(^^)
git branch new_name branch_name ~^2^~3: To create new_name of branch at the location which is 1 upward(~), 1 upward to second parent(^2), 1 upward(^), 3 upwards(~3) from the branch_name.

I am studying these from the web https://learngitbranching.js.org/ which is totally free to learn.

Exit mobile version