4 Replies - 448 Views - Last Post: 17 December 2014 - 09:29 PM

#1 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

GIT Reset --hard forces me to push a lot of files

Posted 11 December 2014 - 12:13 AM

Hello,

I wanted to test how "git reset --hard hash_tag" works locally. I want to reset to a specific commit just after doing a "git pull some_branch". On my SourceTree app, I noticed that I need to push "147" and pull "142", which is somewhat scary as that is a lot. What seems to be the problem? see attached image!

Posted Image

I'm working on the developmental branch so ignore the other branches.
Please also ignore the conflict part, as I'm only concern as to why I need to push and pull a lot of files.

If I do a "git push", whats the worst thing that could happen? like, the remote branch will be messed up?

I'm currently stuck on this, any help would be much appreciated!

Thanks in advance..

This post has been edited by mensahero: 11 December 2014 - 12:16 AM


Is This A Good Question/Topic? 0
  • +

Replies To: GIT Reset --hard forces me to push a lot of files

#2 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2155
  • View blog
  • Posts: 4,525
  • Joined: 11-December 07

Re: GIT Reset --hard forces me to push a lot of files

Posted 11 December 2014 - 05:16 AM

I don't know so here is how I would approach finding out...

Clone a new repo from the remote to somewhere on your system.
Clone another new repo from your working copy.
Change the remotes on the second of these clones to point at the first of these clones.

Now you have an identical setup which if you break, you can just delete.
Was This Post Helpful? 1
  • +
  • -

#3 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GIT Reset --hard forces me to push a lot of files

Posted 11 December 2014 - 06:15 AM

Yes, seems like my current local branch is totally messed up. I'm currently doing exactly those steps. Thanks for info. ^_^

I'm still curious though as to why it end up with so many push and pull counts. :(
Was This Post Helpful? 0
  • +
  • -

#4 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2155
  • View blog
  • Posts: 4,525
  • Joined: 11-December 07

Re: GIT Reset --hard forces me to push a lot of files

Posted 15 December 2014 - 04:42 AM

Did you ever do any history rewriting stuff?
Was This Post Helpful? 0
  • +
  • -

#5 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 8473
  • View blog
  • Posts: 14,662
  • Joined: 19-March 11

Re: GIT Reset --hard forces me to push a lot of files

Posted 17 December 2014 - 09:29 PM

View Postmensahero, on 11 December 2014 - 02:13 AM, said:

Hello,

I wanted to test how "git reset --hard hash_tag" works locally. I want to reset to a specific commit just after doing a "git pull some_branch". On my SourceTree app, I noticed that I need to push "147" and pull "142", which is somewhat scary as that is a lot. What seems to be the problem? see attached image!


From the git book:

Quote

git reset --hard commit:
This variant changes the HEAD ref to point to the given commit. THe contents of your index are also modified to agree with the tree structure named by the commit. Furthermore, your working directory contents are changed to reflect the state of the tree represented by the given commit.


Note that this changes your local HEAD, not the HEAD of some upstream branch.

Quote

If I do a "git push", whats the worst thing that could happen? like, the remote branch will be messed up?


Generally, when you're dealing with version control, the worst that can happen to the repository - the remote branch - is you have to untangle something and merge around whatever you just did. After all, that's sort of the point of version control, it keeps track of versions - so you can always go back to the previous version. In fact the hardest thing to do in any version control system that I know of is any long-term damage.
(though you might have to work a little bit to untangle it - I guess that's short-term damage)

Now, you WILL lose anything in your working directory that isn't reflected in the commit you reset to - as noted above, your working directory contents are changed, and no backup is made. That might be awkward for you if you've got code there that you care about. But that's damage to you, not to the repo, so the rest of the world will be fine.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1