How to set different commit message for directories and files
up vote
-1
down vote
favorite
I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:
root_directory/sub_directory/file_1
root_directory/sub_directory/file_2
cd root_directory
When committing like this...
git commit -m "file_1 description" sub_directory/file_1
git commit -m "file_2 description" sub_directory/file_2
... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:
1) file_1 gets description: "file_1 description"
2) file_2 gets description: "file_2 description"
3) sub_directory gets description: "file_2 description"
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
git
add a comment |
up vote
-1
down vote
favorite
I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:
root_directory/sub_directory/file_1
root_directory/sub_directory/file_2
cd root_directory
When committing like this...
git commit -m "file_1 description" sub_directory/file_1
git commit -m "file_2 description" sub_directory/file_2
... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:
1) file_1 gets description: "file_1 description"
2) file_2 gets description: "file_2 description"
3) sub_directory gets description: "file_2 description"
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
git
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:
root_directory/sub_directory/file_1
root_directory/sub_directory/file_2
cd root_directory
When committing like this...
git commit -m "file_1 description" sub_directory/file_1
git commit -m "file_2 description" sub_directory/file_2
... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:
1) file_1 gets description: "file_1 description"
2) file_2 gets description: "file_2 description"
3) sub_directory gets description: "file_2 description"
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
git
I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:
root_directory/sub_directory/file_1
root_directory/sub_directory/file_2
cd root_directory
When committing like this...
git commit -m "file_1 description" sub_directory/file_1
git commit -m "file_2 description" sub_directory/file_2
... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:
1) file_1 gets description: "file_1 description"
2) file_2 gets description: "file_2 description"
3) sub_directory gets description: "file_2 description"
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
git
git
edited Nov 10 at 10:36
CodeWizard
49.1k126688
49.1k126688
asked Nov 10 at 10:23
Jane Mänd
1
1
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
When you commit git apply the commit message to all the files in the index.
If you wish to give different commit to each file(s) simply add them one by one and commit.
# Add file 1
git add sub_directory/file_1
# now your file 1 will get the desired message
git commit -m "file_1 description"
...
# Add file 2
git add sub_directory/file_2 && git commit -m "file_2 description"
In shorts: how git commit work
When you execute git commit
git take a snapshot of all your files in the index.
Those files are the ones from the previous commit along with the new/modified ones.
git commit -m...
simply take the snapshot and generate metadata for it with the following information
The content of this commit is the following:
And all those files gets the same commit message
add a comment |
up vote
0
down vote
These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)
As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.
Incidentally:
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init
in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
1
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
|
show 1 more comment
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
When you commit git apply the commit message to all the files in the index.
If you wish to give different commit to each file(s) simply add them one by one and commit.
# Add file 1
git add sub_directory/file_1
# now your file 1 will get the desired message
git commit -m "file_1 description"
...
# Add file 2
git add sub_directory/file_2 && git commit -m "file_2 description"
In shorts: how git commit work
When you execute git commit
git take a snapshot of all your files in the index.
Those files are the ones from the previous commit along with the new/modified ones.
git commit -m...
simply take the snapshot and generate metadata for it with the following information
The content of this commit is the following:
And all those files gets the same commit message
add a comment |
up vote
0
down vote
When you commit git apply the commit message to all the files in the index.
If you wish to give different commit to each file(s) simply add them one by one and commit.
# Add file 1
git add sub_directory/file_1
# now your file 1 will get the desired message
git commit -m "file_1 description"
...
# Add file 2
git add sub_directory/file_2 && git commit -m "file_2 description"
In shorts: how git commit work
When you execute git commit
git take a snapshot of all your files in the index.
Those files are the ones from the previous commit along with the new/modified ones.
git commit -m...
simply take the snapshot and generate metadata for it with the following information
The content of this commit is the following:
And all those files gets the same commit message
add a comment |
up vote
0
down vote
up vote
0
down vote
When you commit git apply the commit message to all the files in the index.
If you wish to give different commit to each file(s) simply add them one by one and commit.
# Add file 1
git add sub_directory/file_1
# now your file 1 will get the desired message
git commit -m "file_1 description"
...
# Add file 2
git add sub_directory/file_2 && git commit -m "file_2 description"
In shorts: how git commit work
When you execute git commit
git take a snapshot of all your files in the index.
Those files are the ones from the previous commit along with the new/modified ones.
git commit -m...
simply take the snapshot and generate metadata for it with the following information
The content of this commit is the following:
And all those files gets the same commit message
When you commit git apply the commit message to all the files in the index.
If you wish to give different commit to each file(s) simply add them one by one and commit.
# Add file 1
git add sub_directory/file_1
# now your file 1 will get the desired message
git commit -m "file_1 description"
...
# Add file 2
git add sub_directory/file_2 && git commit -m "file_2 description"
In shorts: how git commit work
When you execute git commit
git take a snapshot of all your files in the index.
Those files are the ones from the previous commit along with the new/modified ones.
git commit -m...
simply take the snapshot and generate metadata for it with the following information
The content of this commit is the following:
And all those files gets the same commit message
edited Nov 10 at 10:35
answered Nov 10 at 10:27
CodeWizard
49.1k126688
49.1k126688
add a comment |
add a comment |
up vote
0
down vote
These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)
As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.
Incidentally:
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init
in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
1
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
|
show 1 more comment
up vote
0
down vote
These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)
As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.
Incidentally:
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init
in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
1
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
|
show 1 more comment
up vote
0
down vote
up vote
0
down vote
These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)
As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.
Incidentally:
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init
in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).
These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)
As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.
Incidentally:
Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?
I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init
in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).
edited Nov 11 at 2:47
answered Nov 10 at 10:27
David Z
93.6k17197236
93.6k17197236
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
1
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
|
show 1 more comment
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
1
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Are you sure you mean “git doesn’t store files, but changes”?
– evolutionxbox
Nov 11 at 2:19
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
– David Z
Nov 11 at 2:22
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
– evolutionxbox
Nov 11 at 2:26
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
– David Z
Nov 11 at 2:29
1
1
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
– David Z
Nov 11 at 2:49
|
show 1 more comment
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%2f53237997%2fhow-to-set-different-commit-message-for-directories-and-files%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