* How to maintain private/secret/confidential branch. @ 2008-12-14 13:49 Łukasz Lew 2008-12-14 14:55 ` Nick Andrew 0 siblings, 1 reply; 11+ messages in thread From: Łukasz Lew @ 2008-12-14 13:49 UTC (permalink / raw) To: git Hi, I don't know how to make such a scenario work: - two repositories: pub, priv - priv is clone/branch of pub - there is some constant developement both in pub and priv - there are regular syncs with pub in priv Problem: Occasionally I want to push some changes from priv to pub. Then after syncing with pub I want to get as few conflicts as possible. Is it possible to do with git? Thanks Lukasz ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-14 13:49 How to maintain private/secret/confidential branch Łukasz Lew @ 2008-12-14 14:55 ` Nick Andrew 2008-12-14 15:38 ` Łukasz Lew 0 siblings, 1 reply; 11+ messages in thread From: Nick Andrew @ 2008-12-14 14:55 UTC (permalink / raw) To: Łukasz Lew; +Cc: git On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: > I don't know how to make such a scenario work: > - two repositories: pub, priv > - priv is clone/branch of pub > - there is some constant developement both in pub and priv > - there are regular syncs with pub in priv > > Problem: > Occasionally I want to push some changes from priv to pub. > Then after syncing with pub I want to get as few conflicts as possible. > > Is it possible to do with git? Git can do almost anything. One should instead ask "How to do this with git?" :-) If I understand your problem, you could solve it with git cherry-pick and rebase. On priv, make a for-public branch from a pub branch. Then cherry-pick the commits you want from your private branch into the for-public branch. Push your for-public branch to pub, then rebase your private branch. Nick. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-14 14:55 ` Nick Andrew @ 2008-12-14 15:38 ` Łukasz Lew 2008-12-14 16:06 ` Alexander Potashev 2008-12-14 16:13 ` Sitaram Chamarty 0 siblings, 2 replies; 11+ messages in thread From: Łukasz Lew @ 2008-12-14 15:38 UTC (permalink / raw) To: Nick Andrew; +Cc: git Thanks Nick, thats really helpful (and surprisingly simple). I have a couple more questions: On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: >> I don't know how to make such a scenario work: >> - two repositories: pub, priv >> - priv is clone/branch of pub >> - there is some constant developement both in pub and priv >> - there are regular syncs with pub in priv >> >> Problem: >> Occasionally I want to push some changes from priv to pub. >> Then after syncing with pub I want to get as few conflicts as possible. >> >> Is it possible to do with git? > > Git can do almost anything. One should instead ask "How to do this > with git?" :-) So I've heard, but not yet experienced it myself. I'm thrilled to try. > > If I understand your problem, you could solve it with git cherry-pick > and rebase. On priv, make a for-public branch from a pub branch. Then > cherry-pick the commits you want from your private branch into the > for-public branch. That almost works. Can I somehow split existing commits just like in git-add -p? > Push your for-public branch to pub, > then rebase your private branch. Rebase to the tip of master? Is it needed? Ie. cherry-pick does not remove the patch from the master in priv. If I now pull from pub, I will get the same change and it mereges nicely :D Can I get away without creating for_pub branch? maybe cherry pick in pub from priv somehow? > > Nick. > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-14 15:38 ` Łukasz Lew @ 2008-12-14 16:06 ` Alexander Potashev 2008-12-14 16:48 ` Łukasz Lew 2008-12-14 16:13 ` Sitaram Chamarty 1 sibling, 1 reply; 11+ messages in thread From: Alexander Potashev @ 2008-12-14 16:06 UTC (permalink / raw) To: Łukasz Lew; +Cc: Nick Andrew, git Hello, Łukasz! On 16:38 Sun 14 Dec , Łukasz Lew wrote: > Thanks Nick, thats really helpful (and surprisingly simple). > I have a couple more questions: > > On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: > > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: > >> I don't know how to make such a scenario work: > >> - two repositories: pub, priv > >> - priv is clone/branch of pub > >> - there is some constant developement both in pub and priv > >> - there are regular syncs with pub in priv > >> > >> Problem: > >> Occasionally I want to push some changes from priv to pub. > >> Then after syncing with pub I want to get as few conflicts as possible. > >> > >> Is it possible to do with git? > > > > Git can do almost anything. One should instead ask "How to do this > > with git?" :-) > > So I've heard, but not yet experienced it myself. I'm thrilled to try. > > > > > If I understand your problem, you could solve it with git cherry-pick > > and rebase. On priv, make a for-public branch from a pub branch. Then > > cherry-pick the commits you want from your private branch into the > > for-public branch. > > That almost works. Can I somehow split existing commits just like in git-add -p? It's, however, better to make more commits to not experience the need of commit splitting. But you can use '--no-commit' option of 'git cherry-pick' and 'git merge' (and 'git pull' as well as 'git merge'). For example: git cherry-pick --no-commit <sha1> # cherry-pick without commiting git reset -- # unstage all changes git add -p # patch update You can also use 'git add -i' (interative mode) instead of 'git add -p'. > > > Push your for-public branch to pub, > > then rebase your private branch. > > Rebase to the tip of master? Is it needed? Ie. cherry-pick does not > remove the patch from > the master in priv. > > If I now pull from pub, I will get the same change and it mereges nicely :D > > Can I get away without creating for_pub branch? maybe cherry pick in > pub from priv somehow? > > > > > Nick. > > Alexander ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-14 16:06 ` Alexander Potashev @ 2008-12-14 16:48 ` Łukasz Lew 2008-12-15 20:31 ` Daniel Barkalow 0 siblings, 1 reply; 11+ messages in thread From: Łukasz Lew @ 2008-12-14 16:48 UTC (permalink / raw) To: Alexander Potashev; +Cc: Nick Andrew, git Hi Alexander, On Sun, Dec 14, 2008 at 17:06, Alexander Potashev <aspotashev@gmail.com> wrote: > Hello, Łukasz! > > On 16:38 Sun 14 Dec , Łukasz Lew wrote: >> Thanks Nick, thats really helpful (and surprisingly simple). >> I have a couple more questions: >> >> On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: >> > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: >> >> I don't know how to make such a scenario work: >> >> - two repositories: pub, priv >> >> - priv is clone/branch of pub >> >> - there is some constant developement both in pub and priv >> >> - there are regular syncs with pub in priv >> >> >> >> Problem: >> >> Occasionally I want to push some changes from priv to pub. >> >> Then after syncing with pub I want to get as few conflicts as possible. >> >> >> >> Is it possible to do with git? >> > >> > Git can do almost anything. One should instead ask "How to do this >> > with git?" :-) >> >> So I've heard, but not yet experienced it myself. I'm thrilled to try. >> >> > >> > If I understand your problem, you could solve it with git cherry-pick >> > and rebase. On priv, make a for-public branch from a pub branch. Then >> > cherry-pick the commits you want from your private branch into the >> > for-public branch. >> >> That almost works. Can I somehow split existing commits just like in git-add -p? > It's, however, better to make more commits to not experience the need of > commit splitting. Indeed good advice and best practice, but another best practice is to not commit not compiling state. My common scenario is that I code a big change in priv repository, and after that I find that some of its parts can and should be moved to pub. > > But you can use '--no-commit' option of 'git cherry-pick' and 'git merge' > (and 'git pull' as well as 'git merge'). For example: > > git cherry-pick --no-commit <sha1> # cherry-pick without commiting > git reset -- # unstage all changes > git add -p # patch update > > You can also use 'git add -i' (interative mode) instead of 'git add -p'. That's a possible solution indeed. Now I see that the right "plumbing" I need is splitting a commit into smaller parts and merging several commits into a larger one. I think that would be nice functionality. Do you know any tool that would allow such a manipulation on commits in history? Thanks Lukasz > >> >> > Push your for-public branch to pub, >> > then rebase your private branch. >> >> Rebase to the tip of master? Is it needed? Ie. cherry-pick does not >> remove the patch from >> the master in priv. >> >> If I now pull from pub, I will get the same change and it mereges nicely :D >> >> Can I get away without creating for_pub branch? maybe cherry pick in >> pub from priv somehow? >> >> > >> > Nick. >> > > > Alexander > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-14 16:48 ` Łukasz Lew @ 2008-12-15 20:31 ` Daniel Barkalow 2008-12-17 19:57 ` Łukasz Lew 0 siblings, 1 reply; 11+ messages in thread From: Daniel Barkalow @ 2008-12-15 20:31 UTC (permalink / raw) To: Łukasz Lew; +Cc: Alexander Potashev, Nick Andrew, git [-- Attachment #1: Type: TEXT/PLAIN, Size: 3783 bytes --] On Sun, 14 Dec 2008, Łukasz Lew wrote: > Hi Alexander, > > On Sun, Dec 14, 2008 at 17:06, Alexander Potashev <aspotashev@gmail.com> wrote: > > Hello, Łukasz! > > > > On 16:38 Sun 14 Dec , Łukasz Lew wrote: > >> Thanks Nick, thats really helpful (and surprisingly simple). > >> I have a couple more questions: > >> > >> On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: > >> > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: > >> >> I don't know how to make such a scenario work: > >> >> - two repositories: pub, priv > >> >> - priv is clone/branch of pub > >> >> - there is some constant developement both in pub and priv > >> >> - there are regular syncs with pub in priv > >> >> > >> >> Problem: > >> >> Occasionally I want to push some changes from priv to pub. > >> >> Then after syncing with pub I want to get as few conflicts as possible. > >> >> > >> >> Is it possible to do with git? > >> > > >> > Git can do almost anything. One should instead ask "How to do this > >> > with git?" :-) > >> > >> So I've heard, but not yet experienced it myself. I'm thrilled to try. > >> > >> > > >> > If I understand your problem, you could solve it with git cherry-pick > >> > and rebase. On priv, make a for-public branch from a pub branch. Then > >> > cherry-pick the commits you want from your private branch into the > >> > for-public branch. > >> > >> That almost works. Can I somehow split existing commits just like in git-add -p? > > It's, however, better to make more commits to not experience the need of > > commit splitting. > > Indeed good advice and best practice, but another best practice is to > not commit not compiling state. In your private branches, it's actually good practice to commit all sorts of junk. That way, when you mess up badly while trying to get it to compile, you won't have lost your work. Of course, that means your commits are going to need more cleanup before going public. > My common scenario is that I code a big change in priv repository, and > after that I find that some of its parts can and should be moved to > pub. I usually end up with my private branch containing the public branch, plus a bunch of commits that introduce: bugs, later fixed; mixed improvements; and debugging cruft. I want to generate nice commits that are individual improvements. I generally do: $ git checkout -b submit origin/master (the first time, to set it up) $ git checkout submit $ git diff submit mixed-work look at it for good changes, find some in file1 and file2 $ git diff submit mixed-work -- file1 file2 | git apply Sometimes, clean up bits that aren't ideal $ git add -i Add the good parts $ git checkout . (revert the working tree to the index) $ make test (did I extract the change correctly?) $ git commit Write a good message, sign off, etc $ git checkout mixed-work $ git rebase -i submit Often, resolve easy conflicts where my mixed-work branch introduced bugs that I fixed later and have now adopted the fixed code Then I repeat until I don't have any more good changes in mixed-work (either I have nothing, only debugging cruft, or only stuff I haven't gotten to work yet). If there's nothing but cruft, I've fully merged the topic, and I delete the branch. Eventually, I'm satisfied with what I've cleaned up, and I do: $ git push origin submit:master Also, I generally have a bunch of "mixed-work" branches, each containing different stuff that isn't ready. I'll periodicly go through all of them and rebase onto "submit" or "origin/master" (or, sometimes, give up on them and delete them). (One thing that would be nice to have is a "git apply --interactive" which applies the user's choice of hunks, like "git add -i" adds them) -Daniel *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-15 20:31 ` Daniel Barkalow @ 2008-12-17 19:57 ` Łukasz Lew 2008-12-17 20:27 ` Daniel Barkalow 0 siblings, 1 reply; 11+ messages in thread From: Łukasz Lew @ 2008-12-17 19:57 UTC (permalink / raw) To: Daniel Barkalow; +Cc: Alexander Potashev, Nick Andrew, git Well, I am still a beginner in git. I just switched from mercurial. Some inline follows: 2008/12/15 Daniel Barkalow <barkalow@iabervon.org>: > On Sun, 14 Dec 2008, Łukasz Lew wrote: > >> Hi Alexander, >> >> On Sun, Dec 14, 2008 at 17:06, Alexander Potashev <aspotashev@gmail.com> wrote: >> > Hello, Łukasz! >> > >> > On 16:38 Sun 14 Dec , Łukasz Lew wrote: >> >> Thanks Nick, thats really helpful (and surprisingly simple). >> >> I have a couple more questions: >> >> >> >> On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: >> >> > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: >> >> >> I don't know how to make such a scenario work: >> >> >> - two repositories: pub, priv >> >> >> - priv is clone/branch of pub >> >> >> - there is some constant developement both in pub and priv >> >> >> - there are regular syncs with pub in priv >> >> >> >> >> >> Problem: >> >> >> Occasionally I want to push some changes from priv to pub. >> >> >> Then after syncing with pub I want to get as few conflicts as possible. >> >> >> >> >> >> Is it possible to do with git? >> >> > >> >> > Git can do almost anything. One should instead ask "How to do this >> >> > with git?" :-) >> >> >> >> So I've heard, but not yet experienced it myself. I'm thrilled to try. >> >> >> >> > >> >> > If I understand your problem, you could solve it with git cherry-pick >> >> > and rebase. On priv, make a for-public branch from a pub branch. Then >> >> > cherry-pick the commits you want from your private branch into the >> >> > for-public branch. >> >> >> >> That almost works. Can I somehow split existing commits just like in git-add -p? >> > It's, however, better to make more commits to not experience the need of >> > commit splitting. >> >> Indeed good advice and best practice, but another best practice is to >> not commit not compiling state. > > In your private branches, it's actually good practice to commit all sorts > of junk. That way, when you mess up badly while trying to get it to > compile, you won't have lost your work. Of course, that means your commits > are going to need more cleanup before going public. I started to follow your advise. Then I rebase -i. I found out I need more precise commit messages. :) > >> My common scenario is that I code a big change in priv repository, and >> after that I find that some of its parts can and should be moved to >> pub. > > I usually end up with my private branch containing the public branch, plus > a bunch of commits that introduce: bugs, later fixed; mixed improvements; > and debugging cruft. I want to generate nice commits that are individual > improvements. I generally do: > $ git checkout -b submit origin/master (the first time, to set it up) > > $ git checkout submit > $ git diff submit mixed-work > look at it for good changes, find some in file1 and file2 > $ git diff submit mixed-work -- file1 file2 | git apply But with this command we do not preserve objects identity. I.e: when you merge with mixed-work you have duplicate changes. Is it ok? > Sometimes, clean up bits that aren't ideal > $ git add -i > Add the good parts > $ git checkout . (revert the working tree to the index) > $ make test (did I extract the change correctly?) > $ git commit > Write a good message, sign off, etc > $ git checkout mixed-work > $ git rebase -i submit ... Ah I see, we throw away old commits anyway with rebasing. > Often, resolve easy conflicts where my mixed-work branch introduced bugs > that I fixed later and have now adopted the fixed code > > Then I repeat until I don't have any more good changes in mixed-work > (either I have nothing, only debugging cruft, or only stuff I haven't > gotten to work yet). If there's nothing but cruft, I've fully merged the > topic, and I delete the branch. > > Eventually, I'm satisfied with what I've cleaned up, and I do: > $ git push origin submit:master > > Also, I generally have a bunch of "mixed-work" branches, each containing > different stuff that isn't ready. I'll periodicly go through all of them > and rebase onto "submit" or "origin/master" (or, sometimes, give up on > them and delete them). > > (One thing that would be nice to have is a "git apply --interactive" which > applies the user's choice of hunks, like "git add -i" adds them) I totally agree. I would appriciate rebase --copy option, which doesn't move, but copy the changelists like cherry-pick. Then we could use rebase -i (with edit) instead of apply. PS Why after edit in rebase -i the change is already commited? I always have to reset;add -i > > -Daniel > *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-17 19:57 ` Łukasz Lew @ 2008-12-17 20:27 ` Daniel Barkalow 2008-12-17 22:31 ` Łukasz Lew 0 siblings, 1 reply; 11+ messages in thread From: Daniel Barkalow @ 2008-12-17 20:27 UTC (permalink / raw) To: Łukasz Lew; +Cc: Alexander Potashev, Nick Andrew, git [-- Attachment #1: Type: TEXT/PLAIN, Size: 6752 bytes --] On Wed, 17 Dec 2008, Łukasz Lew wrote: > Well, I am still a beginner in git. I just switched from mercurial. > Some inline follows: > > 2008/12/15 Daniel Barkalow <barkalow@iabervon.org>: > > On Sun, 14 Dec 2008, Łukasz Lew wrote: > > > >> Hi Alexander, > >> > >> On Sun, Dec 14, 2008 at 17:06, Alexander Potashev <aspotashev@gmail.com> wrote: > >> > Hello, Łukasz! > >> > > >> > On 16:38 Sun 14 Dec , Łukasz Lew wrote: > >> >> Thanks Nick, thats really helpful (and surprisingly simple). > >> >> I have a couple more questions: > >> >> > >> >> On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: > >> >> > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: > >> >> >> I don't know how to make such a scenario work: > >> >> >> - two repositories: pub, priv > >> >> >> - priv is clone/branch of pub > >> >> >> - there is some constant developement both in pub and priv > >> >> >> - there are regular syncs with pub in priv > >> >> >> > >> >> >> Problem: > >> >> >> Occasionally I want to push some changes from priv to pub. > >> >> >> Then after syncing with pub I want to get as few conflicts as possible. > >> >> >> > >> >> >> Is it possible to do with git? > >> >> > > >> >> > Git can do almost anything. One should instead ask "How to do this > >> >> > with git?" :-) > >> >> > >> >> So I've heard, but not yet experienced it myself. I'm thrilled to try. > >> >> > >> >> > > >> >> > If I understand your problem, you could solve it with git cherry-pick > >> >> > and rebase. On priv, make a for-public branch from a pub branch. Then > >> >> > cherry-pick the commits you want from your private branch into the > >> >> > for-public branch. > >> >> > >> >> That almost works. Can I somehow split existing commits just like in git-add -p? > >> > It's, however, better to make more commits to not experience the need of > >> > commit splitting. > >> > >> Indeed good advice and best practice, but another best practice is to > >> not commit not compiling state. > > > > In your private branches, it's actually good practice to commit all sorts > > of junk. That way, when you mess up badly while trying to get it to > > compile, you won't have lost your work. Of course, that means your commits > > are going to need more cleanup before going public. > > I started to follow your advise. > Then I rebase -i. > I found out I need more precise commit messages. :) One useful strategy is to have a second shell and do "git show <hash>" to figure out what you did in that misc commit. > >> My common scenario is that I code a big change in priv repository, and > >> after that I find that some of its parts can and should be moved to > >> pub. > > > > I usually end up with my private branch containing the public branch, plus > > a bunch of commits that introduce: bugs, later fixed; mixed improvements; > > and debugging cruft. I want to generate nice commits that are individual > > improvements. I generally do: > > $ git checkout -b submit origin/master (the first time, to set it up) > > > > $ git checkout submit > > $ git diff submit mixed-work > > look at it for good changes, find some in file1 and file2 > > $ git diff submit mixed-work -- file1 file2 | git apply > > But with this command we do not preserve objects identity. > I.e: when you merge with mixed-work you have duplicate changes. > Is it ok? Git is very good about recognizing duplicate changes in 3-way situations. That is, merging two branches, each of which makes the same change (on a hunk level) to a common ancestor. It'll identify this as "the branches agree on a change" rather than "the branches conflict". Also, "rebase" will try the 3-way merge mechanism, so it will be able to sort this out. The interesting case is when both branches have the same logical change, but one of them is done better than the other. When you merge these, you'll have to select the better one by hand in a conflict resolution. > > Sometimes, clean up bits that aren't ideal > > $ git add -i > > Add the good parts > > $ git checkout . (revert the working tree to the index) > > $ make test (did I extract the change correctly?) > > $ git commit > > Write a good message, sign off, etc > > $ git checkout mixed-work > > $ git rebase -i submit > > ... Ah I see, we throw away old commits anyway with rebasing. Yup. The old commits are there to save us when we make good changes and undo them before getting to a finished state. Once we reach a finished state, we intend to throw them away. > > Often, resolve easy conflicts where my mixed-work branch introduced bugs > > that I fixed later and have now adopted the fixed code > > > > Then I repeat until I don't have any more good changes in mixed-work > > (either I have nothing, only debugging cruft, or only stuff I haven't > > gotten to work yet). If there's nothing but cruft, I've fully merged the > > topic, and I delete the branch. > > > > Eventually, I'm satisfied with what I've cleaned up, and I do: > > $ git push origin submit:master > > > > Also, I generally have a bunch of "mixed-work" branches, each containing > > different stuff that isn't ready. I'll periodicly go through all of them > > and rebase onto "submit" or "origin/master" (or, sometimes, give up on > > them and delete them). > > > > (One thing that would be nice to have is a "git apply --interactive" which > > applies the user's choice of hunks, like "git add -i" adds them) > > I totally agree. > > I would appriciate rebase --copy option, which doesn't move, but copy > the changelists like cherry-pick. There's work in progress on a generalization of "rebase -i" that could be seeded with the "cherry-pick" operations instead of the "rebase" operations. I think that's what you'd like. On the other hand, remember that you can just make a new branch based on your endpoint and rebase it on your upstream; there's no reason that you can't "unzip" the history past the point where the branch you're modifying was created. > Then we could use rebase -i (with edit) instead of apply. > > PS > Why after edit in rebase -i the change is already commited? I always > have to reset;add -i There's (currently) no equivalent of the index (storing the contents of the commit in progress) for the message (and author info, etc). On the other hand, you can use "git commit --amend" to alter the commit on top (including the files), and you can do "git diff HEAD HEAD^ | git apply" to get reverts into your worktree that you can add (or not add). The common case for edit, I think, is that things are mostly correct, but there's a wrong change; with the change already committed, it's easy to change it to what it should be and "git commit -a --amend". -Daniel *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-17 20:27 ` Daniel Barkalow @ 2008-12-17 22:31 ` Łukasz Lew 2008-12-18 8:03 ` Daniel Barkalow 0 siblings, 1 reply; 11+ messages in thread From: Łukasz Lew @ 2008-12-17 22:31 UTC (permalink / raw) To: Daniel Barkalow; +Cc: Alexander Potashev, Nick Andrew, git 2008/12/17 Daniel Barkalow <barkalow@iabervon.org>: > On Wed, 17 Dec 2008, Łukasz Lew wrote: > >> Well, I am still a beginner in git. I just switched from mercurial. >> Some inline follows: >> >> 2008/12/15 Daniel Barkalow <barkalow@iabervon.org>: >> > On Sun, 14 Dec 2008, Łukasz Lew wrote: >> > >> >> Hi Alexander, >> >> >> >> On Sun, Dec 14, 2008 at 17:06, Alexander Potashev <aspotashev@gmail.com> wrote: >> >> > Hello, Łukasz! >> >> > >> >> > On 16:38 Sun 14 Dec , Łukasz Lew wrote: >> >> >> Thanks Nick, thats really helpful (and surprisingly simple). >> >> >> I have a couple more questions: >> >> >> >> >> >> On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: >> >> >> > On Sun, Dec 14, 2008 at 02:49:50PM +0100, Łukasz Lew wrote: >> >> >> >> I don't know how to make such a scenario work: >> >> >> >> - two repositories: pub, priv >> >> >> >> - priv is clone/branch of pub >> >> >> >> - there is some constant developement both in pub and priv >> >> >> >> - there are regular syncs with pub in priv >> >> >> >> >> >> >> >> Problem: >> >> >> >> Occasionally I want to push some changes from priv to pub. >> >> >> >> Then after syncing with pub I want to get as few conflicts as possible. >> >> >> >> >> >> >> >> Is it possible to do with git? >> >> >> > >> >> >> > Git can do almost anything. One should instead ask "How to do this >> >> >> > with git?" :-) >> >> >> >> >> >> So I've heard, but not yet experienced it myself. I'm thrilled to try. >> >> >> >> >> >> > >> >> >> > If I understand your problem, you could solve it with git cherry-pick >> >> >> > and rebase. On priv, make a for-public branch from a pub branch. Then >> >> >> > cherry-pick the commits you want from your private branch into the >> >> >> > for-public branch. >> >> >> >> >> >> That almost works. Can I somehow split existing commits just like in git-add -p? >> >> > It's, however, better to make more commits to not experience the need of >> >> > commit splitting. >> >> >> >> Indeed good advice and best practice, but another best practice is to >> >> not commit not compiling state. >> > >> > In your private branches, it's actually good practice to commit all sorts >> > of junk. That way, when you mess up badly while trying to get it to >> > compile, you won't have lost your work. Of course, that means your commits >> > are going to need more cleanup before going public. >> >> I started to follow your advise. >> Then I rebase -i. >> I found out I need more precise commit messages. :) > > One useful strategy is to have a second shell and do "git show <hash>" to > figure out what you did in that misc commit. Indeed! > >> >> My common scenario is that I code a big change in priv repository, and >> >> after that I find that some of its parts can and should be moved to >> >> pub. >> > >> > I usually end up with my private branch containing the public branch, plus >> > a bunch of commits that introduce: bugs, later fixed; mixed improvements; >> > and debugging cruft. I want to generate nice commits that are individual >> > improvements. I generally do: >> > $ git checkout -b submit origin/master (the first time, to set it up) >> > >> > $ git checkout submit >> > $ git diff submit mixed-work >> > look at it for good changes, find some in file1 and file2 >> > $ git diff submit mixed-work -- file1 file2 | git apply >> >> But with this command we do not preserve objects identity. >> I.e: when you merge with mixed-work you have duplicate changes. >> Is it ok? > > Git is very good about recognizing duplicate changes in 3-way situations. > That is, merging two branches, each of which makes the same change (on a > hunk level) to a common ancestor. It'll identify this as "the branches > agree on a change" rather than "the branches conflict". Also, "rebase" > will try the 3-way merge mechanism, so it will be able to sort this out. I found that already. And I have to say that I am delighted. This is absolutely splendid. > > The interesting case is when both branches have the same logical change, > but one of them is done better than the other. When you merge these, > you'll have to select the better one by hand in a conflict resolution. > >> > Sometimes, clean up bits that aren't ideal >> > $ git add -i >> > Add the good parts >> > $ git checkout . (revert the working tree to the index) >> > $ make test (did I extract the change correctly?) >> > $ git commit >> > Write a good message, sign off, etc >> > $ git checkout mixed-work >> > $ git rebase -i submit >> >> ... Ah I see, we throw away old commits anyway with rebasing. > > Yup. The old commits are there to save us when we make good changes and > undo them before getting to a finished state. Once we reach a finished > state, we intend to throw them away. > >> > Often, resolve easy conflicts where my mixed-work branch introduced bugs >> > that I fixed later and have now adopted the fixed code >> > >> > Then I repeat until I don't have any more good changes in mixed-work >> > (either I have nothing, only debugging cruft, or only stuff I haven't >> > gotten to work yet). If there's nothing but cruft, I've fully merged the >> > topic, and I delete the branch. >> > >> > Eventually, I'm satisfied with what I've cleaned up, and I do: >> > $ git push origin submit:master >> > >> > Also, I generally have a bunch of "mixed-work" branches, each containing >> > different stuff that isn't ready. I'll periodicly go through all of them >> > and rebase onto "submit" or "origin/master" (or, sometimes, give up on >> > them and delete them). >> > >> > (One thing that would be nice to have is a "git apply --interactive" which >> > applies the user's choice of hunks, like "git add -i" adds them) >> >> I totally agree. >> >> I would appriciate rebase --copy option, which doesn't move, but copy >> the changelists like cherry-pick. > > There's work in progress on a generalization of "rebase -i" that could be > seeded with the "cherry-pick" operations instead of the "rebase" > operations. I think that's what you'd like. I always wanted to have system that would allow me manipulation of patches as features. I.e: I have one patch for feature X, one for Y, one for debugging X, one for debugging Y, etc. Then I would just pick some of them, work with them to create new ones. The basic operations would be use/unuse patch, combine sequence of patches into one (with commit messages of subpatches saved somewhere), uncombine patch into sequence of patches. Easy way of spliting atomic patch (diff) into several more so I can add more commit messages. Now this would resemble directory structure, I could copy/move/remove patches from/to various bigger packs of patches. Merging would detect duplicates of course. Git took me for the first time close to this ideal. > On the other hand, remember > that you can just make a new branch based on your endpoint and rebase it > on your upstream; there's no reason that you can't "unzip" the history > past the point where the branch you're modifying was created. I never thought about that. It works indeed. > >> Then we could use rebase -i (with edit) instead of apply. >> >> PS >> Why after edit in rebase -i the change is already commited? I always >> have to reset;add -i > > There's (currently) no equivalent of the index (storing the contents of > the commit in progress) for the message (and author info, etc). On the > other hand, you can use "git commit --amend" to alter the commit on top > (including the files), and you can do "git diff HEAD HEAD^ | git apply" to > get reverts into your worktree that you can add (or not add). Good idea, thanks. BTW is it diff | apply the same as revert --no-commit? > > The common case for edit, I think, is that things are mostly correct, but > there's a wrong change; with the change already committed, it's easy to > change it to what it should be and "git commit -a --amend". > > -Daniel > *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-17 22:31 ` Łukasz Lew @ 2008-12-18 8:03 ` Daniel Barkalow 0 siblings, 0 replies; 11+ messages in thread From: Daniel Barkalow @ 2008-12-18 8:03 UTC (permalink / raw) To: Łukasz Lew; +Cc: Alexander Potashev, Nick Andrew, git [-- Attachment #1: Type: TEXT/PLAIN, Size: 5090 bytes --] On Wed, 17 Dec 2008, Łukasz Lew wrote: > >> > Often, resolve easy conflicts where my mixed-work branch introduced bugs > >> > that I fixed later and have now adopted the fixed code > >> > > >> > Then I repeat until I don't have any more good changes in mixed-work > >> > (either I have nothing, only debugging cruft, or only stuff I haven't > >> > gotten to work yet). If there's nothing but cruft, I've fully merged the > >> > topic, and I delete the branch. > >> > > >> > Eventually, I'm satisfied with what I've cleaned up, and I do: > >> > $ git push origin submit:master > >> > > >> > Also, I generally have a bunch of "mixed-work" branches, each containing > >> > different stuff that isn't ready. I'll periodicly go through all of them > >> > and rebase onto "submit" or "origin/master" (or, sometimes, give up on > >> > them and delete them). > >> > > >> > (One thing that would be nice to have is a "git apply --interactive" which > >> > applies the user's choice of hunks, like "git add -i" adds them) > >> > >> I totally agree. > >> > >> I would appriciate rebase --copy option, which doesn't move, but copy > >> the changelists like cherry-pick. > > > > There's work in progress on a generalization of "rebase -i" that could be > > seeded with the "cherry-pick" operations instead of the "rebase" > > operations. I think that's what you'd like. > > I always wanted to have system that would allow me manipulation of > patches as features. > I.e: I have one patch for feature X, one for Y, one for debugging X, > one for debugging Y, etc. > Then I would just pick some of them, work with them to create new ones. > > The basic operations would be use/unuse patch, combine sequence of > patches into one (with commit messages of subpatches saved somewhere), > uncombine patch into sequence of patches. > Easy way of spliting atomic patch (diff) into several more so I can > add more commit messages. > > Now this would resemble directory structure, I could copy/move/remove > patches from/to various bigger packs of patches. Merging would detect > duplicates of course. > > Git took me for the first time close to this ideal. Git works from the point of view of a developer producing the ideal development history that doesn;t (necessarily) include false starts, bugs fixed in private, and changes mixed together. Or rather, git allows a developer to make commits again knowing the full outcome of the series. It also works from the point of view of a maintainer who merges or does not merge the output of developers working in this mode. It doesn't really quite handle the work of an integrator whose work is to manage a patch queue. I think it needs some additional tools which allow the user do work which consists of operations like "replace this patch/branch with a new version", "suppress this patch/branch", "reorder these patches/branches", and the main thing: "produce a version of my current series with conflict resolutions" This would actually be really helpful to have explicitly represented, so that people could actually bisect the -mm series to find the operation that Andrew did that caused a problem to enter the series, which would be something like adding a patch that doesn't work with other patches in the series. Note that this is different from bisecting within the failing state of the -mm tree, which finds where the series seen as a difference from mainline, fails; if you know that -mm yesterday works and -mm today fails, the difference might be that a branch merged early in the series was updated to a version incompatible with a branch later in the series that hasn't changed, and you'd want to finger the update rather than the point in the series where kernels start failing. > > On the other hand, remember > > that you can just make a new branch based on your endpoint and rebase it > > on your upstream; there's no reason that you can't "unzip" the history > > past the point where the branch you're modifying was created. > > I never thought about that. It works indeed. There's a lot you can do when branches are as cheap and flexible as git's branches are. > >> Then we could use rebase -i (with edit) instead of apply. > >> > >> PS > >> Why after edit in rebase -i the change is already commited? I always > >> have to reset;add -i > > > > There's (currently) no equivalent of the index (storing the contents of > > the commit in progress) for the message (and author info, etc). On the > > other hand, you can use "git commit --amend" to alter the commit on top > > (including the files), and you can do "git diff HEAD HEAD^ | git apply" to > > get reverts into your worktree that you can add (or not add). > > Good idea, thanks. > BTW is it diff | apply the same as revert --no-commit? Largely, although you can give the diff/apply pair paths you want to revert, and not revert the whole thing. And the second commit can be anything with the diff/apply pair, not just HEAD^, which is what revert does, so it's a worthwhile generalization to understand. -Daniel *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to maintain private/secret/confidential branch. 2008-12-14 15:38 ` Łukasz Lew 2008-12-14 16:06 ` Alexander Potashev @ 2008-12-14 16:13 ` Sitaram Chamarty 1 sibling, 0 replies; 11+ messages in thread From: Sitaram Chamarty @ 2008-12-14 16:13 UTC (permalink / raw) To: git On 2008-12-14, Łukasz Lew <lukasz.lew@gmail.com> wrote: > On Sun, Dec 14, 2008 at 15:55, Nick Andrew <nick@nick-andrew.net> wrote: >> If I understand your problem, you could solve it with git cherry-pick >> and rebase. On priv, make a for-public branch from a pub branch. Then >> cherry-pick the commits you want from your private branch into the >> for-public branch. > > That almost works. Can I somehow split existing commits > just like in git-add -p? This is going to sound weird to some seasoned folks, and I'm hoping to hear better ways of doing this. But having done stuff like this, I once wrote it up and here're my notes: To split just the top commit into multiple commits: * start git gui * choose "amend last commit" from the commit menu * unstage all files (meaning you click on the little icons so they move from the left-bottom panel to the left-top panel) * pick files or hunks in files to stage and commit the usual way * continue all changes are committed To split a commit that is *not* the top one: * start an interactive rebase that includes that commit * mark that commit as "edit" and start the rebase * when the rebase pauses, use git gui as described above To combine a set of commits and split the result in some other way (meaning you have commits A B P Q C D R E S and you want to make them A B C D X Y Z where X+Y+Z = P+Q+R+S!) * start an interactive rebase * move lines as appropriate (in the editor) so the commits P,Q,R,S are together * choose "squash" on the second and subsequent ones and start the rebase * (dirty trick warning) when the editor for the combined commit message pops up, delete ALL the lines and save * use git gui as above * then continue the rebase Hope this helps... ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-12-18 8:05 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-12-14 13:49 How to maintain private/secret/confidential branch Łukasz Lew 2008-12-14 14:55 ` Nick Andrew 2008-12-14 15:38 ` Łukasz Lew 2008-12-14 16:06 ` Alexander Potashev 2008-12-14 16:48 ` Łukasz Lew 2008-12-15 20:31 ` Daniel Barkalow 2008-12-17 19:57 ` Łukasz Lew 2008-12-17 20:27 ` Daniel Barkalow 2008-12-17 22:31 ` Łukasz Lew 2008-12-18 8:03 ` Daniel Barkalow 2008-12-14 16:13 ` Sitaram Chamarty
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).