Search code examples
gitversion-controlbranching-and-mergingcollaboration

Best way to make current git history accessible to view for others


When I work with other people, I often like to take a look at what they've done so far or I would like to let them know what I've been doing.

Let me note that in such a state, the code may be unusable in a way that a new feature disturbs something and I am just trying to figure out how to resolve this, so the commit itself might not be “finished”.

Is there any efficient way of giving them a possibility to view my commits without having to create a new remote branch?

A Remote branch has severe disadvantages for this task, because

  • I will very likely change significant parts of the git history with git rebase --interactive or do amend committing
  • Others should not be able to interfere with my work
  • I neither want to remove old branches (in this case I am not even permitted to do so) nor inflate the remote git history with a new temporary branch every time I want to show others my changes.

Solution

  • If what you want to provide is read-only access or some other kind of access control, you probably want to look into repository browsing/management software.

    However, if you are sharing your work with a trusted user, you can ask them to create new remotes. This fulfills your #1 and #3 desires of not polluting your origin with extra branches.

    Given you are a-host and you want to share your my-repo.git with b-host, a user on b-host can do the following:

    b@b-host$ git remote add wip git-user@a-host:/my-repo.git
    b@b-host$ git remote show
    origin
    wip
    b@b-host$ git checkout wip/master
    

    Beware that user b@b-host can write to your local(on a-host) repository in this case, because you must necessarily have granted it access to some git-user on your machine.