git commit -m "add test.txt": fatal: Unable to create 'test/.git/indexlock': Permissions denied

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
5,964
Reaction score
4,437
Credits
43,807
@Bit-10101
Also, git isn’t flagging the new directory you added because it is empty.
If you create a couple of files in the directory and then run git status it will flag the files in the sub-directory as untracked!
Yeah I discovered that some time ago myself, I just remembered that. I find it strange that git wasn't seeing any changes for @Bit-10101. When I create a new file in the repository directory git sees the new file, that being the reason why I thought it might be something in OP's git configuration.
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,710
Reaction score
2,477
Credits
13,760
It all seems normal to me.
This is my terminal output from a quick session:
1. Create a directory, cd inside and run git init:
[email protected] ~
$ mkdir gittest

[email protected] ~
$ cd gittest

[email protected] ~/gittest
$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/jason/gittest/.git/

2. Create a file and an empty directory:
[email protected] ~/gittest
$ touch testfile

[email protected] ~/gittest
$ mkdir dir

3. Run git status:
[email protected] ~/gittest
$ git status
On branch master

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
testfile

nothing added to commit but untracked files present (use "git add" to track)
In the above - because the directory called dir is empty, git has not flagged it. It has only flagged the file testfile as untracked.

4. add a file called testfile2 in dir and run git status:
[email protected] ~/gittest
$ touch dir/testfile2

[email protected] ~/gittest
$ git status
On branch master

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
dir/
testfile

nothing added to commit but untracked files present (use "git add" to track)
Now we see dir as untracked - it doesn't list any of the files, but because dir is not empty - it now shows up.

5. Add testfile and the file in dir and run git status:
[email protected] ~/gittest
$ git add testfile dir/*

[email protected] ~/gittest
$ git status
On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: dir/testfile2
new file: testfile
So now git lists dir/testfile2 and ./testfile as changes to be committed.

6. Just as a proof - let's try adding the directory dir and run git status again:
[email protected] ~/gittest
$ git add dir

[email protected] ~/gittest
$ git status
On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: dir/testfile2
new file: testfile
So - that made no difference. Adding the directory made no difference whatsoever. It still lists the files testfile and dir/testfile2.

7. Make a commit:
[email protected] ~/gittest
$ git commit -m "Initial commit"
[master (root-commit) ebd2bcb] Initial commit
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 dir/testfile2
create mode 100644 testfile

8. View the git log:
[email protected] ~/gittest
$ git log
commit ebd2bcb543c3e80e40ff52f936338730a82806ac (HEAD -> master)
Author: JasKinasis <myemailaddress<at>somedomain.ext>
Date: Sat Dec 11 12:03:53 2021 +0000

Initial commit
We can see our initial commit.

9. run git status again:
[email protected] ~/gittest
$ git status
On branch master
nothing to commit, working tree clean

[email protected] ~/gittest
$

This is all normal behaviour. The OP is seeing nothing out of the ordinary!
 
OP
B

Bit-10101

Member
Joined
Nov 30, 2021
Messages
52
Reaction score
8
Credits
442
@Bit-10101
Additionally, if you use the command:
Bash:
git log
It should list the commit history of your repo. So you should be able to see any commits you’ve made.
Which from what I can see, should be two commits. The first being where you added test.txt and the second where you added test2.txt.

Also, git isn’t flagging the new directory you added because it is empty.
If you create a couple of files in the directory and then run git status it will flag the files in the sub-directory as untracked!
@JasKinasis
cat~/.gitconfig
git_config.JPG

git log
git_log.JPG


So, I have a local repository, not done any push yet.
As you can see is that my email address appears twice on the screenshot.
-I think I have to read more about setting up a GitLab server or how everyhing works with Git?
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,710
Reaction score
2,477
Credits
13,760
@JasKinasis
cat~/.gitconfig
View attachment 11205
git log
View attachment 11206

So, I have a local repository, not done any push yet.
As you can see is that my email address appears twice on the screenshot.
-I think I have to read more about setting up a GitLab server or how everyhing works with Git?
Yup, you’ve got it!
One of my previous posts in this thread links to a post I made some time back, which talks about setting up a remote.

Btw: instead of posting screenshots, you can copy/paste code from the terminal into the editor here, using code tags.

Either by manually typing the \[code\] \[/code\] tags and pasting your code between them, or by clicking the three dots in the toolbar, next to the ‘insert image’ button. Then select the </> icon, which brings up a little dialog where you can tell it the type of code you’re entering and has an area where you can paste your code. Once you’re done click the Ok/insert button and your code will be added to your post, inside code tags.
 
OP
B

Bit-10101

Member
Joined
Nov 30, 2021
Messages
52
Reaction score
8
Credits
442
Yup, you’ve got it!
One of my previous posts in this thread links to a post I made some time back, which talks about setting up a remote.

Btw: instead of posting screenshots, you can copy/paste code from the terminal into the editor here, using code tags.

Either by manually typing the \[code\] \[/code\] tags and pasting your code between them, or by clicking the three dots in the toolbar, next to the ‘insert image’ button. Then select the </> icon, which brings up a little dialog where you can tell it the type of code you’re entering and has an area where you can paste your code. Once you’re done click the Ok/insert button and your code will be added to your post, inside code tags.
Yes, i´m gonna avoid sceenshots
 
OP
B

Bit-10101

Member
Joined
Nov 30, 2021
Messages
52
Reaction score
8
Credits
442
Sitting right know with a tutorial with just get started with GIT and Ansible
Now its time for - "automate the process
with user (author) and e-mail configuration values"

This tutrial is about create and open a reusable config-file
touch my-git-config.sh
So far so good then the tutorial says:
"just type" code . (with a dot) "then the my-git-config.sh will open so you can paste your comands"
But when I type code . nothing happends. This is what's happends:
Command 'code, not found, did you mean:
..etc
..
.

-Anyone?
(It is possible to just type code and a dot (code .)
Is this really working without installing some more modules/ packs or whatever?)

Soon I´ll be up and running, I hope
2021-12-18: Sorry code . it´s that command that does not work
:)
 
Last edited:

Staff online

Members online


Top