Chapsterj
Chapsterj

Reputation: 6625

override specific branch using git

So I have a few different branches that I work on git. For example right now i'm on branch "test1" and I want to be able to do a pull and override my local work with a specific commit ID on branch "test1". I don't care about the local changes on my local branch of "test1"

Anyone know the commands for that.

Upvotes: 0

Views: 710

Answers (1)

MDrabic
MDrabic

Reputation: 917

I would first recommend resetting your local test1 branch to match its' remote tracking branch by performing:

//from the local test1 branch
git fetch origin
git reset --hard origin/test1

Note: This assumes the remote is named "origin" and the remote branch is named "test1".

Now that you have an up to date mirror of the remote test1 branch, you can create a new branch based on the specific commit you want to work off of. Example:

//from the local test1 branch
git checkout -b <new branch name> <commit id> 
//Example
git checkout -b crazy_idea_branch 06bb7167afbb9f399ea57f1cc5d0daead0dd6703

You can find more detail about git reset on this stack overflow answer.

Upvotes: 1

Related Questions