Hacker News new | ask | show | jobs
by forgotmypw17 2182 days ago
Here's the screwup I experienced, as I understand it:

I started a new branch and developed on it.

I realized that my installs were no longer updating when I did a git pull, because I was no longer committing to master.

So I did a git checkout on the installs, and all was good.

Then, I wanted to merge the branch into master, so I did.

Then I did a "git push".

This is where things got screwed up, I think, because I did not know that, apparently, git does not push the whole tree in this case, only the currently selected branch. (wtf?)

After this, I looked at my local code, and some of my recent changes were gone, because it had either reverted to ... some older fucking version.

And that's when I posted this thread.

1 comments

Git pull is just git fetch+merge

If you are confused at all use them in two steps, that also gives you more options such as (what I think you need in this case) merge remote master into your local branch (git merge origin/master).

Also I don't think you actually lost any code, if you do a checkout of the branch you did your work on, I think it should still be there based on your description.

Also git only pushes the current branch because it is designed to be used more decentralized than it often is: git does not assume you are ready (or want to) share all your branches right now.