1

I've made modifications on my master branch, but I would like to pull the remote master branch and delete the content on my current master branch (overwrite). Could anyone be able to tell me how to do it?

Thanks in advance!

2 Answers 2

2
git reset --hard HEAD       # DESTRUCTIVE. Deletes all uncommitted changes.
git checkout origin/master  # will print a warning 'detached head'.
git branch -D master        # 'kinda' destructive for locally committed changes
git checkout -b master      # recreates a local master branch
git branch --track origin/master  # restores tracking from 'origin' remote
1

Just do a pull, which is fetch + merge:

git pull origin master

Merging the remote origin's master branch into the current local branch.

For rebase-ing (instead of merge-ing), use --rebase:

git pull --rebase origin master
2
  • I have two error : error: Cannot pull with rebase: You have unstaged changes. error: Additionally, your index contains uncommitted changes., but I don't really care about that. Could you help me with that
    – user645479
    Jan 24, 2017 at 4:44
  • @DavidHilbert Why don't you just delete the branch then: git branch --delete <whatever>?
    – heemayl
    Jan 24, 2017 at 4:52

You must log in to answer this question.