How to restrict push to the branch?
We have our server implementation of git repo. I would like to restrict push to the one of the branch of the repo for everyone except of me.
So, I added under .git/hooks/update on server git dir such script
#!/bin/sh
if [ "$USER" != "Aleksey" ] && [ "$1" == refs/heads/test_br ];then
echo "Manual pushing to this repo is restricted"
exit 1
fi
And I see that condition "$USER" != "Aleksey" is always true. Second condition looks like is work good, but name condition not...
Who know what is the problem? Maybe I need to compare with user mail? Or something else?
Feel free to ask
git
add a comment |
We have our server implementation of git repo. I would like to restrict push to the one of the branch of the repo for everyone except of me.
So, I added under .git/hooks/update on server git dir such script
#!/bin/sh
if [ "$USER" != "Aleksey" ] && [ "$1" == refs/heads/test_br ];then
echo "Manual pushing to this repo is restricted"
exit 1
fi
And I see that condition "$USER" != "Aleksey" is always true. Second condition looks like is work good, but name condition not...
Who know what is the problem? Maybe I need to compare with user mail? Or something else?
Feel free to ask
git
add a comment |
We have our server implementation of git repo. I would like to restrict push to the one of the branch of the repo for everyone except of me.
So, I added under .git/hooks/update on server git dir such script
#!/bin/sh
if [ "$USER" != "Aleksey" ] && [ "$1" == refs/heads/test_br ];then
echo "Manual pushing to this repo is restricted"
exit 1
fi
And I see that condition "$USER" != "Aleksey" is always true. Second condition looks like is work good, but name condition not...
Who know what is the problem? Maybe I need to compare with user mail? Or something else?
Feel free to ask
git
We have our server implementation of git repo. I would like to restrict push to the one of the branch of the repo for everyone except of me.
So, I added under .git/hooks/update on server git dir such script
#!/bin/sh
if [ "$USER" != "Aleksey" ] && [ "$1" == refs/heads/test_br ];then
echo "Manual pushing to this repo is restricted"
exit 1
fi
And I see that condition "$USER" != "Aleksey" is always true. Second condition looks like is work good, but name condition not...
Who know what is the problem? Maybe I need to compare with user mail? Or something else?
Feel free to ask
git
git
asked Dec 30 '18 at 19:21
Aleksey TimoshchenkoAleksey Timoshchenko
1,2771734
1,2771734
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
git doesn't have any notion of users. Whatever protocol you use to push to remote $USER is the user under which server-side git operates. For example if you push like git push git@remote-server/repo.git then $USER is always git.
If you want user-based branch protection you need to install something that has a notion of users — gitolite, github, gitlab, etc.
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result ofgit remote show(remove passwords)?
– phd
Dec 31 '18 at 13:10
we are using local file system andgit remote showreturn meorigin...
– Aleksey Timoshchenko
Jan 1 at 9:50
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53980682%2fhow-to-restrict-push-to-the-branch%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
git doesn't have any notion of users. Whatever protocol you use to push to remote $USER is the user under which server-side git operates. For example if you push like git push git@remote-server/repo.git then $USER is always git.
If you want user-based branch protection you need to install something that has a notion of users — gitolite, github, gitlab, etc.
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result ofgit remote show(remove passwords)?
– phd
Dec 31 '18 at 13:10
we are using local file system andgit remote showreturn meorigin...
– Aleksey Timoshchenko
Jan 1 at 9:50
|
show 4 more comments
git doesn't have any notion of users. Whatever protocol you use to push to remote $USER is the user under which server-side git operates. For example if you push like git push git@remote-server/repo.git then $USER is always git.
If you want user-based branch protection you need to install something that has a notion of users — gitolite, github, gitlab, etc.
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result ofgit remote show(remove passwords)?
– phd
Dec 31 '18 at 13:10
we are using local file system andgit remote showreturn meorigin...
– Aleksey Timoshchenko
Jan 1 at 9:50
|
show 4 more comments
git doesn't have any notion of users. Whatever protocol you use to push to remote $USER is the user under which server-side git operates. For example if you push like git push git@remote-server/repo.git then $USER is always git.
If you want user-based branch protection you need to install something that has a notion of users — gitolite, github, gitlab, etc.
git doesn't have any notion of users. Whatever protocol you use to push to remote $USER is the user under which server-side git operates. For example if you push like git push git@remote-server/repo.git then $USER is always git.
If you want user-based branch protection you need to install something that has a notion of users — gitolite, github, gitlab, etc.
answered Dec 30 '18 at 19:54
phdphd
21.7k52544
21.7k52544
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result ofgit remote show(remove passwords)?
– phd
Dec 31 '18 at 13:10
we are using local file system andgit remote showreturn meorigin...
– Aleksey Timoshchenko
Jan 1 at 9:50
|
show 4 more comments
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result ofgit remote show(remove passwords)?
– phd
Dec 31 '18 at 13:10
we are using local file system andgit remote showreturn meorigin...
– Aleksey Timoshchenko
Jan 1 at 9:50
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
but because of we have the remote server implementation of git I can't install something to additional... I can add a script or something like this... Do you have an idea how can I do this, without to install additional soft?
– Aleksey Timoshchenko
Dec 30 '18 at 20:01
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
I don't understand… Do you have your own git implementation? That is, a collection of programs that doesn't use original git but implements git protocol? In that case that implementation has to manage users. And if it doesn't — you're out of luck.
– phd
Dec 30 '18 at 20:35
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, I just have git bare repo on our server side... Did you get?
– Aleksey Timoshchenko
Dec 31 '18 at 7:11
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result of
git remote show (remove passwords)?– phd
Dec 31 '18 at 13:10
No, you cannot have just a bare repo — there have to be a transport level. Either you access the bare repo over ssh, or http(s), or via local filesystem (the transport then is CIFS/SMB, actually, but it doesn't matter). Both ssh and https transports have notion of users but how they're used depends on the server-side configuration which you haven't explained. So the next question is: what transport do you use and how? Can you show the result of
git remote show (remove passwords)?– phd
Dec 31 '18 at 13:10
we are using local file system and
git remote show return me origin...– Aleksey Timoshchenko
Jan 1 at 9:50
we are using local file system and
git remote show return me origin...– Aleksey Timoshchenko
Jan 1 at 9:50
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53980682%2fhow-to-restrict-push-to-the-branch%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown