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

@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.
 


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:
jason@JASONPC ~
$ mkdir gittest

jason@JASONPC ~
$ cd gittest

jason@JASONPC ~/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:
jason@JASONPC ~/gittest
$ touch testfile

jason@JASONPC ~/gittest
$ mkdir dir

3. Run git status:
jason@JASONPC ~/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:
jason@JASONPC ~/gittest
$ touch dir/testfile2

jason@JASONPC ~/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:
jason@JASONPC ~/gittest
$ git add testfile dir/*

jason@JASONPC ~/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:
jason@JASONPC ~/gittest
$ git add dir

jason@JASONPC ~/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:
jason@JASONPC ~/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:
jason@JASONPC ~/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:
jason@JASONPC ~/gittest
$ git status
On branch master
nothing to commit, working tree clean

jason@JASONPC ~/gittest
$

This is all normal behaviour. The OP is seeing nothing out of the ordinary!
 
@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
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.
 
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
 
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:

Members online


Latest posts

Top