I
I
Ivan2020-08-07 14:12:21
git
Ivan, 2020-08-07 14:12:21

Is it possible somehow to completely rewrite a branch with another one from a remote repository with one command?

For example, I'm on the dev branch. And I want to pull the master branch, but so that I have a clean master, without any changes in dev. Through git pull it doesn’t fit, because then it will merge, but I don’t want to merge. Is it possible to do something like this in one fell swoop, without deleting locally, globally, etc.?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Zagaevsky, 2020-08-07
@zagayevskiy

Ummm,
git fetch origin master
git checkout master
?

A
Alexey Yarkov, 2020-08-07
@yarkov

git reset --hard origin/master

N
Nikita Pushkar, 2020-08-07
@NickPush

git fetch
will first help you get all the branches from the external - then check out as much as you need.
git checkout master
so as not to spoil the master - in general, I recommend making a new branch from the master and merging into this branch - if the merge has not entered, then it is easy to roll back to a clean master

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question