Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

version control - GIT - How to make a branch be the same as master

I have a website using git

The setup has the master branch as the live site and a develop branch as the dev domain which is used for testing features before they go live

No work is ever done directly on master or develop, it's always done on feature branches and then merged in to develop for testing, followed by master to go live

My issue is that I have one site which has had a lot of work merged in to the develop branch which is never going to go live

I've been asked to make the develop branch match the master branch to ensure the work that's never going live doesn't affect the testing of other new features that get merged in to develop

I've done a bit of research and from my understanding, I can't use rebase as that's more for updating a branch with commits made since you branched off

The only option that seems to do what I need is to rename the develop branch and then recreate it from master and force a push to update it remotely

Is this my best option? Or is there another way I don't know about? Or maybe rebase is correct but I'm not quite understanding its purpose?

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you don't care about preserving develop just checkout develop and reset it to master.

# make sure master is up to date before you do this
git checkout develop
git reset --hard master
git push -f # force push the branch

This is often done for an integration branch every morning, so that the nightly integration is always based on master.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...