V
V
vrazbros2019-04-04 00:04:03
git
vrazbros, 2019-04-04 00:04:03

How can you push changes from one branch to another without switching?

For example, I'm on branch v1, how can I merge changes from it or, more precisely, merge it with another local branch v2 without switching to v2?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
coderisimo, 2019-04-04
@coderisimo

# Merge local branch foo into local branch master,
# without having to checkout master first.
# Here `.` means to use the local repository as the "remote":
git fetch . foo:master

M
Maxim Moseychuk, 2019-04-04
@fshp

You can use worktree. Technically, you still switch to the branch, but in a different directory. Your working directory will remain untouched.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question