-1

I'm using Git 2.1.60 for Windows and I want to push my directory to my github URL

Suppose I have a directory: Mydir

and there is "a.txt" in Mydir.

I want to commit only Directory. But when I type like this:

git add Mydir
git commit -m "Mydirectory"
git push origin master

Then in my github, commit message is updated not only directory but also files in Mydir.

I just want to show commit message only Mydir.

So I changed a.txt file and i tried this:

git add Mydir/a.txt
git commit -m "this is a.txt"

What I want is

Mydir     "Mydirectory"

And if I click Mydir in github,

a.txt     "this is a.txt"

But When I type like this(same as above code):

git add Mydir/a.txt
git commit -m "this is a.txt"

The resuls is

Mydir     "this is a.txt"

And if I click Mydir in github,

a.txt     "this is a.txt"

How can I just commit only directory?

or How can I just commit only a.txt file?

Is it impossible?

mathcom
  • 113
  • 1
  • 7

1 Answers1

1

You can't, there is no point tracking empty directory, there is no such way in git. The history of directory will follow its contents. However you can do what you want, if I am not mistaken, using like .gitkeep or other dotfiles.

Just create file named .gitkeep in directory that you want to track. So if you want certain history for your directory, then just modify the .gitkeep

touch mydir/.gitkeep git add mydir/.gitkeep git commit -m "something"

something will only applied to mydir and .gitkeep file

egig
  • 4,370
  • 5
  • 29
  • 50