LogIn
I don't have account.

How can i get a specific commit changes form other branch?

i have a branch test-1 and pushed 3-4 commit on it. i am working on another branch test-2. i require a specific commit from branch 1 in my current branch but not all other commits how can i do this?

Please pay attention to update your answer.

Update Your Answer care fully. After saving you can not recover your old answer

Carefully Update Your Answer!!
  1. Find the commit hash from test-1:

    git checkout test-1 git log --oneline

    Example output:

    a1b2c3d Commit A d4e5f6g Commit B h7i8j9k Commit C

    Suppose you need only d4e5f6g.

  2. Switch to your current branch (test-2):

    git checkout test-2

  3. Cherry-pick the commit:

    git cherry-pick d4e5f6g

    This applies the changes from that commit onto test-2.

Please pay attention to update your answer.

Update Your Answer care fully. After saving you can not recover your old answer

Carefully Update Your Answer!!
  1. Switch to your target branch

    git switch test-2
    
  2. Find the commit hash from the other branch

    git log test-1 --oneline
    

     Copy the required commit hash (e.g. a1b2c3d)

  3. Cherry-pick that commit

    git cherry-pick a1b2c3d
    
  4. If conflicts occur

    git add .
    git cherry-pick --continue 

 Only that specific commit’s changes from test-1 will be applied to test-2.

Please pay attention to update your answer.

Update Your Answer care fully. After saving you can not recover your old answer

Carefully Update Your Answer!!

you can achieve this by : Temporary Branch + Merge

Use this method when you want to take only one commit from another branch, test it in isolation and then merge it cleanly.

# Switch to the source branch (where the commit exists)
git switch test-1
# Makes sure you're on the branch containing the desired commit.

# Create a temporary branch from that specific commit
git checkout -b temp-pick a1b2c3d
# Creates a new branch "temp-pick" that starts exactly from that commit.

# Switch to your target branch
git switch test-2
# Moves to the branch where you want to apply the commit.

# Merge the temporary branch into the target branch
git merge temp-pick --no-ff -m "Merged commit a1b2c3d from test-1" 
# Applies the isolated commit to test-2 and creates a merge commit for clear history.

# Delete the temporary branch after successful merge
git branch -d temp-pick
# Cleans up the helper branch since it’s no longer needed. 

The specific commit from test-1 is safely merged into test-2, keeping both branches clean, traceable, and easy to revert if needed.