# Bad git pull

**URL:** <https://www.ruby-forum.com/t/bad-git-pull/174030>\
**Category:** Rails\
**Created:** [August 19, 2009, 5:47pm UTC](https://www.ruby-forum.com/t/bad-git-pull/174030 "2009-08-19T17:47:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 19, 2009, 5:47pm UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/1 "2009-08-19T17:47:23Z")

</div>

You pull. You have conflicts. You want to go back to how it was before  
pulling and push your version. How do you do that without editing the  
file line by line?

---

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 19, 2009, 6:13pm UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/2 "2009-08-19T18:13:14Z")

</div>

Milan D. wrote:

> You pull. You have conflicts. You want to go back to how it was before  
> pulling and push your version. How do you do that without editing the  
> file line by line?

Use git mergetool?

Anyway, this question is probably better asked in a Git forum.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 19, 2009, 8:53pm UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/3 "2009-08-19T20:53:22Z")

</div>

Milan D. wrote:

> You pull. You have conflicts. You want to go back to how it was before  
> pulling and push your version. How do you do that without editing the  
> file line by line?

If conflicts occur during a pull the auto-merge should fail leaving the  
changes in your working tree. At this point you should be able to run:

git reset --hard

to return your working tree to the tip of the current branch.

P.S. I agree this question would be more appropriate for a git forum.

---

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 19, 2009, 9:00pm UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/4 "2009-08-19T21:00:13Z")

</div>

Marnen Laibow-Koser wrote:

> Milan D. wrote:
> 
> > You pull. You have conflicts. You want to go back to how it was before  
> > pulling and push your version. How do you do that without editing the  
> > file line by line?
> 
> Use git mergetool?

Milan, If you are interested in seeing a short demonstration of conflict  
resolution in git you can watch my screencast on the subject here:

[![](https://i.vimeocdn.com/video/19782185-bb7361174ad16bb9821c78490f1ca2e94a0b4f1c0a575d3aea7d8e363253011f-d "Conflict Resolution in Git (Git Series, pt2)") ](https://vimeo.com/5728959)

---

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 19, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/5 "2009-08-19T22:51:39Z")

</div>

2009/8/19 Milan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ## You pull. You have conflicts. You want to go back to how it was before pulling and push your version. How do you do that without editing the file line by line?

Just checkout your version from your local repository again. If the  
pull failed due to conflicts then so will a push, in fact I believe it  
is always best to pull, sort the conflicts, commit then push.

Colin

---

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 20, 2009, 12:09am UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/6 "2009-08-20T00:09:28Z")

</div>

Colin L. wrote:

> Just checkout your version from your local repository again. If the  
> pull failed due to conflicts then so will a push, in fact I believe it  
> is always best to pull, sort the conflicts, commit then push.

From man git-merge:  
HOW TO RESOLVE CONFLICTS  
After seeing a conflict, you can do two things:

```
   o Decide not to merge. The only clean-ups you need are to reset 

```

the index file to the HEAD  
commit to reverse 2. and to clean up working tree changes  
made by 2. and 3.; git-reset  
–hard can be used for this.

git pull is basically git fetch + git merge. If conflicts occur this  
should happen in the git merge phase. From that point you can choose to  
resolve the conflicts and commit or, as stated above, choose not to  
merge. Using git reset --hard can be used for the later as I stated in  
an earlier post.

---

<div class="post-metadata">

**Author:** ![milandobrota](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@milandobrota](https://www.ruby-forum.com/u/milandobrota)\
**Post date:** [August 21, 2009, 2:09am UTC](https://www.ruby-forum.com/t/bad-git-pull/174030/7 "2009-08-21T02:09:47Z")

</div>

Thank you guys. git merge tool is awesome!!! 🙂
