Ing. Michal Hudak
Ing. Michal Hudak

Reputation: 5612

GIT - get changes from branch to master as changes

I have master and develop branch.

In develop branch I have commit1.

Question:

How to add changes from commit1(develop) to master branch as local changes (uncomitted changes)?

Upvotes: 1

Views: 118

Answers (2)

Roman
Roman

Reputation: 20246

Most common workflow in git is to just continue working on a branch until you feature is finish or bug is fixed and then merge it back into its parent branch (in your case master).

However, if you do want to bring changes from one branch over into the other, you have a few options.

  1. Use the git merge command as Landys mentioned. Either --no-commit or --squash will bring changes from another branch over without actually committing them. You'll probably need to do a git reset to unstage the changes that you just merged in. This will bring all the changes from all of the commits over.
  2. Another option is described here: Quick tip: git-checkout specific files from another branch. Basically you can use git checkout to specify a specific file you want to check out from another branch or use patch mode (-p) to select which changes you want to check out from the other branch and which you don't.
  3. If you have several commits on another branch and you want to bring only one of them over to your current branch, you could use git cherry-pick to bring that commit over and then git reset HEAD~ to undo the commit cherry-pick made but not modify the files in your working directory.

Upvotes: 0

Landys
Landys

Reputation: 7727

Use git merge in master branch.

git merge develop

If you want to merge without commit, just add --no-commit and --no-ff.

git merge develop --no-commit --no-ff

Upvotes: 1

Related Questions