Posted in Code Snippets, GIT

Git pull : Ignoring local changes

When you are in a situation to initiate git to a directory which is already developed and you need to pull changes from the remote ignoring local changes, you will not be allowed to use:

git pull origin master

In such case, after initializing git using git init you need to hard reset the head.

Step 0: Git Initialization

git init
git remote add origin<repo>

Step 1: Fetch all the changes from the remote

git fetch --all

Step 2: Reset the master branch now

git reset --hard origin/master

Step 3: Pull from master

git pull origin master




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s