Xaree Lee
Xaree Lee

Reputation: 3387

Git: overwrite all files in a repository from another commit

I have two branches. One is develop for development; the other branch is passed which will have test-passed commits from develop.

We will open a branch to develop a new feature and merge it back to branch develop when it's done, and we will test all new merged commits in develop by CI server.

When a test passes, we want to merge that commit into branch passed from develop and overwrite all files in the repository of old branch passed. That means, we want to do overwrite, not merge, and all files in the commits of the branch passed should be exactly the same to corresponding commits of the branch develop.

Branch passed tracks the test-passed commits and we will release the latest passed commit for beta testing.

The question is, how to overwrite a branch but not merge into a branch from the branch develop?

BTW, I want to keep two separated branches.

Upvotes: 0

Views: 104

Answers (2)

Enrico Campidoglio
Enrico Campidoglio

Reputation: 59963

It sounds like what you want is to have the passed branch point to the exact same commit as develop once the tests have passed.

You can do it with git branch --force:

git branch --force passed develop

Here's from the git branch documentation:

-f
--force
Reset <branchname> to <startpoint> if <branchname> exists already. Without -f git branch refuses to change an existing branch.

Upvotes: 1

Pan Long
Pan Long

Reputation: 1032

If this is REALLY what you want. You can delete the passed and create it again from develop, which will result develop to be the same as passed. But are you sure you want to do this? If yes, why don't you just add a tag to that commit in develop?

Upvotes: 0

Related Questions