Wednesday, March 23, 2011

local git check-ins -- hide from main repository?

I thought I remembered reading somewhere a way to do this, but I can't find it.

I'm working locally, on a local branch even, and I'm checking in as needed, or daily or whatever. When I get the code to the point where I want to push it to the main repository, is there a way to just push the file as is, and not push all of the history? Or when I merge from a branch back to main, can I not merge the history?

Are these even good ideas? Thanks for the help -- still learning, here!

joe

From stackoverflow
  • You could merge your changes as a single commit on the main branch:

    $ git checkout main
    $ git merge --squash local
    

    That discards all of your local history, of course. All in all that is not something I would do. Instead, if you’re worried about embarrassing or compromising commits in your local history, use git rebase to rewrite your local history; afterward, perform a normal merge and push out your cleaned-up local history as well.

    Edit/clarification: an interactive rebase will allow you to easily remove or "squash" commits in your history:

    $ git checkout local
    $ git rebase -i main
    

0 comments:

Post a Comment