0

I did git fetch and git fetch --all but there was no output for the same. after that when I do git pull again I get the below error again.

I am willing to fetch the origin from the remote to my local.

I even did this below but still there is an error.

[root@connect /myurl/fd-ansible]# git fetch origin master
Password:
From https://github.com/myurl/fd-ansible
 * branch            master     -> FETCH_HEAD
[root@connect /myurl/fd-ansible]# git clean -df
[root@connect /myurl/fd-ansible]# git pull
Password:
Updating 8bf6b66..a0b2167
error: Your local changes to 'group_vars/system1' would be overwritten by merge.  Aborting.
Please, commit your changes or stash them before you can merge.

Edited with @Stephen Kitt solution

[root@connect /myurl/fd-ansible]# git checkout group_vars/system1
[root@connect /myurl/fd-ansible]# git pull
Password:
Updating 8bf6b66..a0b2167
Fast-forward
 cmdb/vm.csv |  118 +++++++++++++++++++++++++-------------------------
 group_vars/system1       |   56 ++++++++++++++++++++++++
 2 files changed, 115 insertions(+), 59 deletions(-)
AReddy
  • 3,172
  • 5
  • 36
  • 76
  • Use git fetch instead, not that that will fully resolve the situation—you need to understand Git to use it properly. Also, this question would do better on StackOverflow than here. – Wildcard Jan 11 '17 at 02:47
  • How do you resolve it? Well that depends on that you want to do with the changes - do you want to keep them, add them to the repo or ignore them? – muru Jan 11 '17 at 02:48
  • @Wildcard I attempted to run git fetch it was executed without any output. Does that mean it is done with the merge part. – AReddy Jan 11 '17 at 02:50
  • @muru I want to overwrite my local file. let me know how can i do that. – AReddy Jan 11 '17 at 02:54
  • You really need to read the documentation. However, for a starting point which will bring you up from knowing absolutely nothing about Git to actually being able to understand the documentation (which is notoriously difficult for beginners), understand how commits are related and what a commit is, I would recommend this video. – Wildcard Jan 11 '17 at 02:54
  • 1
    http://stackoverflow.com/questions/1125968/how-to-force-git-pull-to-overwrite-local-files – muru Jan 11 '17 at 02:55
  • Question edited with the latest query. – AReddy Jan 11 '17 at 04:17

1 Answers1

1

To overwrite your local file (losing your changes):

git checkout group_vars/system1

Then you should be able to git pull.

Stephen Kitt
  • 434,908