git add <filename> not working - windows

When i am typing
git add *.c
the error shown is
warning: could not open directory 'AppData/Local/Application Data/':
Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission d enied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permissi on denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permissio n denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Documents/My Music/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Documents/My Videos/': Permission denied
0 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
warning: LF will be replaced by CRLF in .atom/packages/script/examples/colored_diagnostics.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .atom/packages/script/examples/hello.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .atom/recovery/stringdel-c5a98d.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump y/distutils/mingw/gfortran_vs2003_hack.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump y/f2py/src/fortranobject.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump y/f2py/tests/src/array_from_pyobj/wrapmodule.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.0/resources/app/apm/node_modules/npm /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.1/resources/app/apm/node_modules/npm /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.2/resources/app/apm/node_modules/npm /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
1241365 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2219951 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2611925 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2758249 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2990144 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3176253 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3360807 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3523597 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3746325 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3964192 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
4150814 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
4335693 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
warning: LF will be replaced by CRLF in Desktop/exploringBB-master/chp03/HelloWorldSleep.c.
....
Please help me. I do not know what to do just to add a file. My repository folder has some files that do not have permission. How do I change these permissions or should I change my repository folder>
I'm currently working under windows.

Seems like you are trying to perform git operations inside your user directory.
C:\Users\{user-name}
Please make sure your git bash or cmd points to correct folder.
I had the same issue and by navigating to correct folder it worked fine for me
As a suggestion use cd foldername then again cd foldername to navigate

You just need to delete log files.
Use the command
rm -rf .git
It will solve your problem. Before entering this command remember one thing that it will clear all your log files and delete .git folder.

in my case, I solved this error by running the following commands:
git init
git add -A
git Commit -a -m "your message"

Be sure u are in the correct path(folder)
then use :
git init
git status

Just change your directory where the actual files are located then list them (ls -l). You will find your file there. once you done this your command will work fine git add <filename>.
What I did is:
sarat#DESKTOP-9BPO08D MINGW64 /d
$ cd files1
sarat#DESKTOP-9BPO08D MINGW64 /d/files1
$ git init
Initialized empty Git repository in D:/files1/.git/
sarat#DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ ls -l
total 1
-rw-r--r-- 1 sarat 197609 396 May 25 21:15 Camera_Follow.cs
sarat#DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ git add Camera_Follow.cs
sarat#DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: Camera_Follow.cs

Seems like you didn't initialised git on you folder,
Start by:
git init
git status
git add -A
it will work

Related

linux permission denied ./file.sh VS bash file.sh

I have the following file xx.sh:
#!/bin/bash
echo "hi"
The permissions are defined as follows:
-rwxr-xr-x 1 root root 22 Nov 22 10:55 xx.sh*
but when I run the file ./xx.sh I get:
**-bash: ./xx.sh: Permission denied**
When running with override: bash xx.sh it runs correctly.
What is the permission issue here?
Your system is probably mounted with noexec. Verify by:
findmnt <folder>
If you have noexec in the OPTIONS, then you are not allowed to execute executable binaries in the mounted file system. You can solve using the mount command.

Use grep to find errors in log and error origin

I have a installation log and I'm greping for errors to another file. To do so, I use the following line of code:
grep -w --ignore-case 'not found\|error\|unable' $DIR/.install.log | grep -vi inflating | grep -vi creating | sort | uniq -c | sort -r >> $DIR/.error.log where $DIR is my current working directory.
The problem is that, using this method, I can't discover where the error came from. Example of installation log:
[+]Metasploit
dpkg: error: dpkg frontend lock is locked by another process
rm: cannot remove 'metasploit*': No such file or directory
dpkg: error: dpkg frontend lock is locked by another process
[+] Burp Suite
Unpacking JRE ...
Starting Installer ...
This will install Burp Suite Community Edition on your computer.
OK [o, Enter], Cancel [c]
Click Next to continue, or Cancel to exit Setup.
Select the folder where you would like Burp Suite Community Edition to be
installed, then click Next.
Where should Burp Suite Community Edition be installed?
[/opt/BurpSuiteCommunity]
./script.sh: line 512: pip3: command not found
/usr/bin/python3: No module named pip
./script.sh: line 514: pipx: command not found
mv: cannot stat '/root/.local/bin/cme': No such file or directory
mv: cannot stat '/root/.local/bin/cmedb': No such file or directory
[+] crackmapexec
mv: cannot stat '/root/.local/bin/crackmapexec': No such file or directory
./script.sh: line 521: pip: command not found
./script.sh: line 532: beef/install: No such file or directory
./script.sh: line 538: ./config/setup.sh: No such file or directory
python3: can't open file 'setup.py': [Errno 2] No such file or directory
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=pt_PT.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs AMD Ryzen 5 2600 Six-Core Processor (800F82),ASM,AES-NI)
Scanning the drive for archives:
1 file, 10122922 bytes (9886 KiB)
With this, I want to be able to somehow grep the "unable" and then grep the previous [+] Hallo? so that the error.log looks like
[+] metasploit
dpkg: error: dpkg frontend lock is locked by another process
rm: cannot remove 'metasploit*': No such file or directory
dpkg: error: dpkg frontend lock is locked by another process
[+] Burp Suite
./script.sh: line 512: pip3: command not found
/usr/bin/python3: No module named pip
./script.sh: line 514: pipx: command not found
mv: cannot stat '/root/.local/bin/cme': No such file or directory
mv: cannot stat '/root/.local/bin/cmedb': No such file or directory
[+] crackmapexec
mv: cannot stat '/root/.local/bin/crackmapexec': No such file or directory
./script.sh: line 521: pip: command not found
./script.sh: line 532: beef/install: No such file or directory
./script.sh: line 538: ./config/setup.sh: No such file or directory
python3: can't open file 'setup.py': [Errno 2] No such file or directory
I hope my question was somewhat understandable... Thanks in advance.

How to access c:\ on a windows machine with gitlab runner and bash as the shell

I have a gitlab runner running on a Windows Server 2012 machine.
I have installed win-bash and added the location of the bash executable to the system path.
I have configured the runners config.toml file to use bash for the shell
I have a python script stored on the machine that I need to run as part of the build process. This script is stored on the windows machine and is located at c:\path\to\script.py
The first line in my build script prints the working directory pwd and returns this: /home/gitlab-runner/builds/2b321e5b/0/Firmware/PSoC5LP
My question is this: How do I get access to the C:\ drive?
I am running on a windows machine, and starting bash from any other terminal (cmd.exe, powershell, running the bash.exe directly) puts me into the standard windows directory structure from wherever I start bash:
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\Administrator\Desktop>bash
bash$ pwd
C:/Users/Administrator/Desktop
bash$ cd /
bash$ pwd
C:/
bash$ cd /home
bash: /home: No such file or directory
bash$ ls
$Recycle.Bin ProgramData
BOOTNXT System Volume Information
Documents and Settings Users
Miniconda2 Windows
Multi-Runner bootmgr
PerfLogs cygwin64
Program Files gitrepos
Program Files (x86) pagefile.sys
bash$
no /home/, not a standard linux directory structure in sight. Because of this, my build scripts fail since they are not able to access the files via there absolute path (I don't even know what their relative paths would look like in the runners bash context)
here is the relevant portion of my build script:
#!/bin/bash
echo "build script executing"
pwd
echo "ls /"
ls /
echo "***assembling the LyteByte asm files"
# move to the LyteByteAssember directory
cd ./LyteByteAssembler/
ASSEMBLY_FILE="LyteByteAssembly.lbasm"
MERGE_FILE="merge.lbasm"
OUTPUT_FILE="../BootloaderProj.cydsn/lytebyte_prog_mem_init.c"
TEMP_DIR="./"
PREPROCESSOR_DIRECTORY="c:/gitrepos/ArcherTools/LyteByteAsembler/LyteBytePreProcessor.py"
echo $PREPROCESSOR_DIRECTORY $ASSEMBLY_FILE $MERGE_FILE $TEMP_DIR
python "$PREPROCESSOR_DIRECTORY" "$ASSEMBLY_FILE" "$MERGE_FILE" "$TEMP_DIR"
if [ $? -eq 0 ]
then
echo "Preprocessing succeeded!"
else
echo "Preprocessing failed, process cancelled"
exit 1
fi
and here is a sample output from the runner:
gitlab-ci-multi-runner 1.1.3 (a470667)
Using Shell executor...
Running on ip-172-31-7-232...
Fetching changes...
HEAD is now at d51e873 hjkj
From https://thing.githost.io/Firmware/PSoC5LP
d51e873..d77e88b CI -> origin/CI
Checking out d77e88b0 as CI...
Previous HEAD position was d51e873... hjkj
HEAD is now at d77e88b... ;jkblkn .,/p
$ bash ./build_script.sh
build script executing
/home/gitlab-runner/builds/2b321e5b/0/Firmware/PSoC5LP
ls /
bin
boot
cgroup
dev
etc
home
lib
lib64
local
lost+found
media
mnt
opt
proc
root
run
sbin
selinux
srv
sys
tmp
usr
var
***assembling the LyteByte asm files
c:/gitrepos/ArcherTools/LyteByteAsembler/LyteBytePreProcessor.py LyteByteAssembly.lbasm merge.lbasm ./
python: can't open file 'c:/gitrepos/ArcherTools/LyteByteAsembler/LyteBytePreProcessor.py': [Errno 2] No such file or directory
Preprocessing failed, process cancelled
It depends on which software you've installed:
If you've installed Git for windows by selecting Git Bash, then you can open Git Bash terminal and browse C: Drive or D: Drive by doing:
cd /c/
cd /c/Windows/
cd /d/
If you've installed cygwin, then you've to do:
cd /cygdrive/c/
Check your manual for win-bash

bash redirect in OSX doesn't work

I try to redirect output from a command in a terminal window in Max OSX (10.9.4) and get an error message. When I try this easy command:
ls > file_list.txt
I get this error:
-bash: file_list.txt: Operation not supported
Anybody an idea?
Thanks
This is the error you get if you try to create a file somewhere like /dev, which is the mount point for a special filesystem that doesn't (ordinarily) allow you to create files:
$ cd /dev
$ ls > file_list.txt
bash: file_list.txt: Permission denied
# Oops, we get permission denied before we even try to create the file.
$ sudo -s
Password:
# ls > file_list.txt
bash: file_list.txt: Operation not supported

Permission denied when piping to a file

I'm trying to pipe the output of a "git pull" command to both a file and stdout using the following script:
STD_OUT=`mktemp`
git pull | $STD_OUT
rm -f $STD_OUT
This results in:
./test.sh: line 2: /tmp/tmp.BITQRbsMSI: Permission denied
error: git-pull died of signal 13
Why am I denied permission to the temp file I just created and what's the alternative?
"Piping to a file" is not a legal operation in bash (or any other shell). The thing following a | has to be a command. If you want to redirect the output from the git operation into the file, use the redirect operator >:
git pull > $STD_OUT

Resources