How to overwrite changes and avoid merge in GIT

I am using GIT. We have a master branch. From this branch we created another branch called test. My friend is making changes in test branch while I am working on master branch.

I pushed my changes to master branch & he also pushed his changes to test branch to repo.

Now if I say

git checkout -b test

git pull origin test I get merge window.

I just want to pull content of test branch and want to overwrite my local change.

How can I avoid merging?

So far I have used this, but I am not sure if this is the right approach

git fetch origin test
git reset --hard FETCH_HEAD

  • Completely manual Mercurial merge
  • How can I get a diff of a file since the last time I merged?
  • How to prevent Gitlab from creating extra merge commit on branch merge
  • git merge omits files within ignored folder?
  • Where's the 3-way Git merge driver for .PO (gettext) files?
  • Why am I getting tree conflicts in Subversion?
  • SVN merge trunk into branch deleting files
  • Git getting all commits of a previously merged branch
  • 2 Solutions collect form web for “How to overwrite changes and avoid merge in GIT”

    If you want to overwrite your local changes which have not been committed, you can:

    git reset HEAD --hard
    git pull origin test

    If your changes have been committed, you can:

    git checkout <commit number>
    git pull origin test

    where commit number is the commit that origin:test branched from.

    You did two things wrong.

    First to create the new branch you should do

    git checkout -t origin/test

    This would avoid any need to pull in the first place.

    Also when you run

    git checkout -b test

    while in master it creates a branch named test with master as base that has no relation to origin/test. When you pull origin/test onto that branch it will try to merge them.

    Git Baby is a git and github fan, let's start git clone.