Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Git Usage 2 - Cherry-pick, Rebase

By editor , 29 September, 2017
Question

How to use cherry-pick ?
How to use rebase ?

How to change the user name or the email of a commit ?

Cherry pick

Example:

#Checkout the branch you want to insert the commits
git checkout hotfix/Bug-123

#Pick the commits
git cherry-pick 09c075bcd46af4bc94f1d2f8341b0b698506fc9c
#Push the branch
git push origin hotfix/Bug-123

 

Rebase

Merge multiple commits in to one

Example : Merge last 4 commits in to one

git rebase -i HEAD~4
# -> Change pick to squash the commit you want to merge
git push -f origin master

 

Change the user name or the email of a commit

Example 01
git -c user.name="New name" -c user.email=new.email@mail.com commit --amend --reset-author
Example 02
git commit --amend --author "New Author Name <email@address.com>"

Using Interactive Rebase (For multiple commits)

git rebase -i -p <some HEAD before all of your bad commits>
Then mark all of your bad commits as "edit" in the rebase file. If you also want to change your first commit, you have to manually add it as first line in the rebase file (follow the format of the other lines). Then, when git asks you to amend each commit, do
git commit --amend --author "New Author Name <email@address.com>"
edit or just close the editor that opens, and then do
git rebase --continue
to continue the rebase.
You could skip opening the editor altogether here by appending --no-edit so that the command will be:
git commit --amend --author "New Author Name <email@address.com>" --no-edit && \
git rebase --continue

 

Update a branch from master or parent branch

git fetch
git rebase origin/master

 

Tags

  • Git
Helpful git commands
Make Correction on a git
Squash commits into one with Git, Rebase

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer