How to understand the structure of git command?
How to understand the structure of git command?
git remote add origin repo-url
In the code above which one is a command and which one is a parameter?
linux git command command-line-interface
add a comment |
How to understand the structure of git command?
git remote add origin repo-url
In the code above which one is a command and which one is a parameter?
linux git command command-line-interface
Read the git man page?
– evolutionxbox
Dec 29 '18 at 14:39
Seriously though, despite my original tone, I do recommend the man pages.man git-remote,man git-commit, etc.
– evolutionxbox
Dec 30 '18 at 10:38
add a comment |
How to understand the structure of git command?
git remote add origin repo-url
In the code above which one is a command and which one is a parameter?
linux git command command-line-interface
How to understand the structure of git command?
git remote add origin repo-url
In the code above which one is a command and which one is a parameter?
linux git command command-line-interface
linux git command command-line-interface
edited Dec 29 '18 at 11:43
Roman Pokrovskij
4,26294980
4,26294980
asked Dec 29 '18 at 10:26
Ehsan sarsharEhsan sarshar
725
725
Read the git man page?
– evolutionxbox
Dec 29 '18 at 14:39
Seriously though, despite my original tone, I do recommend the man pages.man git-remote,man git-commit, etc.
– evolutionxbox
Dec 30 '18 at 10:38
add a comment |
Read the git man page?
– evolutionxbox
Dec 29 '18 at 14:39
Seriously though, despite my original tone, I do recommend the man pages.man git-remote,man git-commit, etc.
– evolutionxbox
Dec 30 '18 at 10:38
Read the git man page?
– evolutionxbox
Dec 29 '18 at 14:39
Read the git man page?
– evolutionxbox
Dec 29 '18 at 14:39
Seriously though, despite my original tone, I do recommend the man pages.
man git-remote, man git-commit, etc.– evolutionxbox
Dec 30 '18 at 10:38
Seriously though, despite my original tone, I do recommend the man pages.
man git-remote, man git-commit, etc.– evolutionxbox
Dec 30 '18 at 10:38
add a comment |
3 Answers
3
active
oldest
votes
There are different command-line interpreters available on different systems, so for some of the details, the OS and/or your chosen shell matter. You mention Linux (via the linux tag), so we might assume you are using bash, dash, fish, zsh, or perhaps even tcsh or some such. These shells all vary slightly but they have a lot of things in common:
They treat the first white-space-separated word as the command. All remaining words are arguments.
They do what the shells call glob expansion, so that instead of programs having to interpret
*.pyfor instance, the program just gets all the.pyfiles as individual arguments.They perform variable expansion, such as replacing
$HOMEwith your home directory.
(This is not the right place to discuss all of these details—find documentation for your particular shell, and read that, and/or read some Unix or Linux programming environment books. StackOverflow and other StackExchange sites do have plenty of specific answers about specific shell programming constructs, though.)
In any case, given the command:
git remote add origin repo-url
the shell's responsibility is to break up the five words into an argument vector: git, remote, add, origin, and repo-url. The zeroth argument1 is the command to run, so the shell then locates this command (using $PATH) and runs it, passing all the arguments—including the command name itself—to the command.
Thus, at this point, the command is git and everything else is an argument to that command. However, the git command itself acts like a miniature, non-interactive shell: it interprets its arguments, such as remote, to figure out which of these is a command. So to Git, remote is a command, with arguments add, origin, and repo-url. Git prefixes the command with git-, then locates the git-remote command—which resides in the directory that git --exec-path will print—and runs that, with arguments add, origin, and url (and zeroth argument git-remote).
So, having passed through the git command into the git-remote command, the arguments are now just add, origin, and url (with the command name git-remote available to git-remote as the zero'th argument).
Note that the git command itself takes (and handles and therefore takes away) some command options. For instance, running:
git --work-tree=/tmp hello world
causes Git to save away the work-tree setting /tmp, then attempt to run the command git-hello with the argument world. You can write your own Git commands by writing, e.g., a git-hello program: git hello will then run your git-hello program. In any case, the --work-tree argument has vanished from the argument list at this point. (Git has stored it in an environment variable, $GIT_WORK_TREE. Environment variables are passed across exec system calls; exec is how the shell runs git and how Git runs its sub-commands.)
1This zeroth argument is often referred to as argv[0], after the naming convention used in C language programming.
add a comment |
git cli book has detailed information on the git command line interface.
in your code, git remote is command and following it are the arguments.
git-remote - Manage set of tracked repositories
Manage the set of repositories ("remotes") whose branches you track.
you can find subcommands for any git command by
git help <git_command>
add a comment |
if you are having difficulty understanding the git CLI you can always use git GUI, which works fine too.
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
add a comment |
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%2f53968701%2fhow-to-understand-the-structure-of-git-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are different command-line interpreters available on different systems, so for some of the details, the OS and/or your chosen shell matter. You mention Linux (via the linux tag), so we might assume you are using bash, dash, fish, zsh, or perhaps even tcsh or some such. These shells all vary slightly but they have a lot of things in common:
They treat the first white-space-separated word as the command. All remaining words are arguments.
They do what the shells call glob expansion, so that instead of programs having to interpret
*.pyfor instance, the program just gets all the.pyfiles as individual arguments.They perform variable expansion, such as replacing
$HOMEwith your home directory.
(This is not the right place to discuss all of these details—find documentation for your particular shell, and read that, and/or read some Unix or Linux programming environment books. StackOverflow and other StackExchange sites do have plenty of specific answers about specific shell programming constructs, though.)
In any case, given the command:
git remote add origin repo-url
the shell's responsibility is to break up the five words into an argument vector: git, remote, add, origin, and repo-url. The zeroth argument1 is the command to run, so the shell then locates this command (using $PATH) and runs it, passing all the arguments—including the command name itself—to the command.
Thus, at this point, the command is git and everything else is an argument to that command. However, the git command itself acts like a miniature, non-interactive shell: it interprets its arguments, such as remote, to figure out which of these is a command. So to Git, remote is a command, with arguments add, origin, and repo-url. Git prefixes the command with git-, then locates the git-remote command—which resides in the directory that git --exec-path will print—and runs that, with arguments add, origin, and url (and zeroth argument git-remote).
So, having passed through the git command into the git-remote command, the arguments are now just add, origin, and url (with the command name git-remote available to git-remote as the zero'th argument).
Note that the git command itself takes (and handles and therefore takes away) some command options. For instance, running:
git --work-tree=/tmp hello world
causes Git to save away the work-tree setting /tmp, then attempt to run the command git-hello with the argument world. You can write your own Git commands by writing, e.g., a git-hello program: git hello will then run your git-hello program. In any case, the --work-tree argument has vanished from the argument list at this point. (Git has stored it in an environment variable, $GIT_WORK_TREE. Environment variables are passed across exec system calls; exec is how the shell runs git and how Git runs its sub-commands.)
1This zeroth argument is often referred to as argv[0], after the naming convention used in C language programming.
add a comment |
There are different command-line interpreters available on different systems, so for some of the details, the OS and/or your chosen shell matter. You mention Linux (via the linux tag), so we might assume you are using bash, dash, fish, zsh, or perhaps even tcsh or some such. These shells all vary slightly but they have a lot of things in common:
They treat the first white-space-separated word as the command. All remaining words are arguments.
They do what the shells call glob expansion, so that instead of programs having to interpret
*.pyfor instance, the program just gets all the.pyfiles as individual arguments.They perform variable expansion, such as replacing
$HOMEwith your home directory.
(This is not the right place to discuss all of these details—find documentation for your particular shell, and read that, and/or read some Unix or Linux programming environment books. StackOverflow and other StackExchange sites do have plenty of specific answers about specific shell programming constructs, though.)
In any case, given the command:
git remote add origin repo-url
the shell's responsibility is to break up the five words into an argument vector: git, remote, add, origin, and repo-url. The zeroth argument1 is the command to run, so the shell then locates this command (using $PATH) and runs it, passing all the arguments—including the command name itself—to the command.
Thus, at this point, the command is git and everything else is an argument to that command. However, the git command itself acts like a miniature, non-interactive shell: it interprets its arguments, such as remote, to figure out which of these is a command. So to Git, remote is a command, with arguments add, origin, and repo-url. Git prefixes the command with git-, then locates the git-remote command—which resides in the directory that git --exec-path will print—and runs that, with arguments add, origin, and url (and zeroth argument git-remote).
So, having passed through the git command into the git-remote command, the arguments are now just add, origin, and url (with the command name git-remote available to git-remote as the zero'th argument).
Note that the git command itself takes (and handles and therefore takes away) some command options. For instance, running:
git --work-tree=/tmp hello world
causes Git to save away the work-tree setting /tmp, then attempt to run the command git-hello with the argument world. You can write your own Git commands by writing, e.g., a git-hello program: git hello will then run your git-hello program. In any case, the --work-tree argument has vanished from the argument list at this point. (Git has stored it in an environment variable, $GIT_WORK_TREE. Environment variables are passed across exec system calls; exec is how the shell runs git and how Git runs its sub-commands.)
1This zeroth argument is often referred to as argv[0], after the naming convention used in C language programming.
add a comment |
There are different command-line interpreters available on different systems, so for some of the details, the OS and/or your chosen shell matter. You mention Linux (via the linux tag), so we might assume you are using bash, dash, fish, zsh, or perhaps even tcsh or some such. These shells all vary slightly but they have a lot of things in common:
They treat the first white-space-separated word as the command. All remaining words are arguments.
They do what the shells call glob expansion, so that instead of programs having to interpret
*.pyfor instance, the program just gets all the.pyfiles as individual arguments.They perform variable expansion, such as replacing
$HOMEwith your home directory.
(This is not the right place to discuss all of these details—find documentation for your particular shell, and read that, and/or read some Unix or Linux programming environment books. StackOverflow and other StackExchange sites do have plenty of specific answers about specific shell programming constructs, though.)
In any case, given the command:
git remote add origin repo-url
the shell's responsibility is to break up the five words into an argument vector: git, remote, add, origin, and repo-url. The zeroth argument1 is the command to run, so the shell then locates this command (using $PATH) and runs it, passing all the arguments—including the command name itself—to the command.
Thus, at this point, the command is git and everything else is an argument to that command. However, the git command itself acts like a miniature, non-interactive shell: it interprets its arguments, such as remote, to figure out which of these is a command. So to Git, remote is a command, with arguments add, origin, and repo-url. Git prefixes the command with git-, then locates the git-remote command—which resides in the directory that git --exec-path will print—and runs that, with arguments add, origin, and url (and zeroth argument git-remote).
So, having passed through the git command into the git-remote command, the arguments are now just add, origin, and url (with the command name git-remote available to git-remote as the zero'th argument).
Note that the git command itself takes (and handles and therefore takes away) some command options. For instance, running:
git --work-tree=/tmp hello world
causes Git to save away the work-tree setting /tmp, then attempt to run the command git-hello with the argument world. You can write your own Git commands by writing, e.g., a git-hello program: git hello will then run your git-hello program. In any case, the --work-tree argument has vanished from the argument list at this point. (Git has stored it in an environment variable, $GIT_WORK_TREE. Environment variables are passed across exec system calls; exec is how the shell runs git and how Git runs its sub-commands.)
1This zeroth argument is often referred to as argv[0], after the naming convention used in C language programming.
There are different command-line interpreters available on different systems, so for some of the details, the OS and/or your chosen shell matter. You mention Linux (via the linux tag), so we might assume you are using bash, dash, fish, zsh, or perhaps even tcsh or some such. These shells all vary slightly but they have a lot of things in common:
They treat the first white-space-separated word as the command. All remaining words are arguments.
They do what the shells call glob expansion, so that instead of programs having to interpret
*.pyfor instance, the program just gets all the.pyfiles as individual arguments.They perform variable expansion, such as replacing
$HOMEwith your home directory.
(This is not the right place to discuss all of these details—find documentation for your particular shell, and read that, and/or read some Unix or Linux programming environment books. StackOverflow and other StackExchange sites do have plenty of specific answers about specific shell programming constructs, though.)
In any case, given the command:
git remote add origin repo-url
the shell's responsibility is to break up the five words into an argument vector: git, remote, add, origin, and repo-url. The zeroth argument1 is the command to run, so the shell then locates this command (using $PATH) and runs it, passing all the arguments—including the command name itself—to the command.
Thus, at this point, the command is git and everything else is an argument to that command. However, the git command itself acts like a miniature, non-interactive shell: it interprets its arguments, such as remote, to figure out which of these is a command. So to Git, remote is a command, with arguments add, origin, and repo-url. Git prefixes the command with git-, then locates the git-remote command—which resides in the directory that git --exec-path will print—and runs that, with arguments add, origin, and url (and zeroth argument git-remote).
So, having passed through the git command into the git-remote command, the arguments are now just add, origin, and url (with the command name git-remote available to git-remote as the zero'th argument).
Note that the git command itself takes (and handles and therefore takes away) some command options. For instance, running:
git --work-tree=/tmp hello world
causes Git to save away the work-tree setting /tmp, then attempt to run the command git-hello with the argument world. You can write your own Git commands by writing, e.g., a git-hello program: git hello will then run your git-hello program. In any case, the --work-tree argument has vanished from the argument list at this point. (Git has stored it in an environment variable, $GIT_WORK_TREE. Environment variables are passed across exec system calls; exec is how the shell runs git and how Git runs its sub-commands.)
1This zeroth argument is often referred to as argv[0], after the naming convention used in C language programming.
answered Dec 29 '18 at 12:13
torektorek
186k18235317
186k18235317
add a comment |
add a comment |
git cli book has detailed information on the git command line interface.
in your code, git remote is command and following it are the arguments.
git-remote - Manage set of tracked repositories
Manage the set of repositories ("remotes") whose branches you track.
you can find subcommands for any git command by
git help <git_command>
add a comment |
git cli book has detailed information on the git command line interface.
in your code, git remote is command and following it are the arguments.
git-remote - Manage set of tracked repositories
Manage the set of repositories ("remotes") whose branches you track.
you can find subcommands for any git command by
git help <git_command>
add a comment |
git cli book has detailed information on the git command line interface.
in your code, git remote is command and following it are the arguments.
git-remote - Manage set of tracked repositories
Manage the set of repositories ("remotes") whose branches you track.
you can find subcommands for any git command by
git help <git_command>
git cli book has detailed information on the git command line interface.
in your code, git remote is command and following it are the arguments.
git-remote - Manage set of tracked repositories
Manage the set of repositories ("remotes") whose branches you track.
you can find subcommands for any git command by
git help <git_command>
answered Dec 29 '18 at 10:37
AuxilusAuxilus
20719
20719
add a comment |
add a comment |
if you are having difficulty understanding the git CLI you can always use git GUI, which works fine too.
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
add a comment |
if you are having difficulty understanding the git CLI you can always use git GUI, which works fine too.
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
add a comment |
if you are having difficulty understanding the git CLI you can always use git GUI, which works fine too.
if you are having difficulty understanding the git CLI you can always use git GUI, which works fine too.
answered Dec 29 '18 at 10:44
HimalayHimalay
43
43
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
add a comment |
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
I don't have difficulty using CLI. but it seem a little not structured I want to know it deeply
– Ehsan sarshar
Dec 29 '18 at 10:50
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
In that case you can use this link if you don't know about , git-scm.com/book/en/v2
– Himalay
Dec 29 '18 at 11:09
add a comment |
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%2f53968701%2fhow-to-understand-the-structure-of-git-command%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
Read the git man page?
– evolutionxbox
Dec 29 '18 at 14:39
Seriously though, despite my original tone, I do recommend the man pages.
man git-remote,man git-commit, etc.– evolutionxbox
Dec 30 '18 at 10:38