1

Problem: In a certain directory, Git push is restricted to very few users(User1). Other users(User2) cannot push their changes here.

Is there a way so that - the User2 commits the changes(git add + Git commit) in that dir, then he provides the commit number to User1 and the latter does the Git push?

Can it be done?

Kara
  • 5,650
  • 15
  • 48
  • 55
Mr. Bordoloi
  • 80
  • 11
  • There are several ways to transfer commits. User2 can mail his commits to User1 who then pushes them for example. So in short, yes. But I assume it should not be possible for User2 to add+commit in that "certain directory", when he is not able to push. It would be better if User2 clones his own repository and does his changes there. – ikrabbe Mar 29 '16 at 06:48

1 Answers1

2

Usually, User2 does the changes and commits them. Then, she provides these changes to User1 who pushes the changes upstream.

The changes can be provided via various mechanisms:

Your requirement is not uncommon: lots of open source projects work just like this: while everybody could contribute changes, it's up to certain (trustworthy) people to integrate these changes into the actual project repository.


Edit
I'll provide some examples for how to use git format-patch or git request-pull here

  1. Create patches for the last 3 commits you did:

    git format-patch -3
    

    This will create 3 patch files that you could send via E-Mail to somebody that is allowed to commit on the upstream repo

  2. Create patches for all commits of the branch my-new-feature since you branched off from master:

    git format-patch master..my-new-feature  
    

    This will take each commit you did in my-new-feature and create a patch from it. Again, send these patches to the maintainer.

  3. Publish your changes to the maintainer directly from your hard disk (Windows):

    • Share your working directory with the maintainer (give her read access), say as \\yourmachine\yourworkingcopy. From now on, the maintainer could read the contents of the shared folder
    • Open up your console and let the magic happen:

      git request-pull origin/master file:////yourmachine/yourworkingcopy my-new-feature
      

      This spits out a ready made E-Mail text to the console that you could take and send to your maintainer.

Community
  • 1
  • 1
eckes
  • 56,506
  • 25
  • 151
  • 189