What should i do to resolve this issue on Git? - windows

I am new to Unix commands and would like to have some help regarding it.
I am want to practice commands on my Windows Machine. I have installed GitBash and I am trying to execute commands on it. But every time I press enter I get this issue:
$ git init
C:/Users/.git: Permission denied
lenovo#LAPTOP-7Q4QK8A7 MINGW64 /c/Users
$ git clone https://github.com/06-glitch/Rainbow/commit/32c6e7cc3c37d20ff368a2095c34522da297b174
fatal: could not create work tree dir '32c6e7cc3c37d20ff368a2095c34522da297b174': Permission denied
Could anyone please help me with this?

Problem:Your are trying to clone in the users folder which is not accessible.
Answer:Change your directory to the Desktop or any other folder and use the git commands
cd means "change directory"
Use the below code to change directory to root:
cd ~
or In my case my desktop name Aakarsh Teja so.. try cd to that name Remember you have to use quotes if your folder name consists of a SPACE.
cd "Aakarsh Teja"/Desktop
Now you can use your commands for git.
Make sure your git bash is in your destination folder.
Aakarsh Teja#MINGW64 ~/Desktop
$git clone <gitlink>

Related

git BASH: why is $HOME concatenation of path?

Some context: trying to clone a repo with ssh url from git BASH, but getting the following error:
Could not create directory '/c/Usersusername/.ssh'
The authenticity of host '...' can't be established.
Why are the Users and username subdirectories getting concatenated? Is this expected? I'm assuming this is causing the error and the failed clone request.
From git BASH:
$ echo $HOME
/c/Usersusername
From Windows cmd:
C:\ echo %HOME%
C:/Users/username
I've tried $ setx home "C:/Users/username" .
Try and not set HOME: by default, git bash should use %USERPROFILE%
Try also to create in advance the .ssh folder, before using your SSH URL for cloning: that way, Git should directly go to the Host verification step, without failing on that folder creation.
Note: On Windows 10, with Git 2.32 for Windows, I do have a HOME set using C:\... backslash path, and it is correctly displayed as /c/... in a bash session without me setting it in .bashrc or .profile.

problems with git bash on windows. i can't access folders on git bash for windows

i bought a course from codecademy and at beginner was a lesson about git bash. I install it , but if i want to change directories with "cd" i cant't.
enter image description here
Also , when i double-click on shortcut the program doesn't run.
Try changing to you home directory first
$ cd
then
$ pwd
/c/Users/yourname
Try going to you root directory with : cd / (make sure you add a space between cd and /)
Then do cd yourfilename/yourfilename....you can add multiple directories
Make sure your spelling is correct
Few other tips :
To navigate to your home directory use "cd ~".
To navigate to the previous directory use "cd -"

Issues with git hooks permissions on Windows

I have a bare git repository running on a Windows machine, and I am trying to have it run a post-receive hook. I have the following in the hooks/post-receive file
cmd //c "activate <some-env> && do-something"
which works nicely if it is run manually from Git Bash. However, it doesn't run after a commit is pushed.
The file's permissions, as obtained from Git Bash by doing ls -lh, are 644. This may be the issue, but chmod +x <file> has no effect. Neither does git update-index --chmod=+x <file>, as suggested elsewhere - this results in fatal: this operation must be run in a work tree (I guess this is not meant for a bare repository). The permisions in the sample hooks are well set, but if I do echo <my-command> > some-hook.sample the execute permissions are lost. This is also the case if I modify the file using e.g. Notepad++.
How does one change the execute permissions in this case?
Thanks!

Git: rename directory (case-only) on Windows

I want to rename a directory versioned by Git on a Windows system (change the case of the directory name):
$ git mv docs DOCS
Rename from 'docs' to 'DOCS/docs' failed. Should I try again? (y/n) n
fatal: renaming 'docs' failed: Permission denied
I've also tried with the force-option - but with the same result:
$ git mv --force docs DOCS
Rename from 'docs' to 'DOCS/docs' failed. Should I try again? (y/n) n
fatal: renaming 'docs' failed: Permission denied
For some reason Git fails because it thinks DOCS already is an existing directory and the directory should be moved inside it. I know that I can rename & commit using a temporary directory name and then rename & amend-commit to the final name, but isn't there a way to tell Git that I don't want to move inside any other directory?
You can try to do it in 2 step.
$ git mv docs DOCS2
$ git mv DOCS2 DOCS
it will work
I have tried to rename my directory with TortoiseGit using rename, command prompt using git mv, and git bash using git mv. The move command was either mv Status status or git mv Status status2 and both of them respond "failed: Permission denied". So it seems I am either going to have to delete the git repository and create a new one with the new directory name structure or I am going to have to create a Linux VM, clone it down, and try to rename name it there. It seems only files can be renamed under windows, but directories just fail. As for people that say git mv works for them, there has to be something missing in your setup.
Since windows iד case sensitive you cant rename the file to the same letters. (Docs == docs [ignored case])
You can do it from git bash since git bash is cygwin and its case sensitive since its a unix emulator.
The command is git mv
git mv <old name> <new name>
Here is a demo from git bash. (windows 7)
No. There isn't a way to tell Git that you don't want to move the folder inside any other directory.
This is not a limitation of git, but rather a limitation of Windows and NTFS. Because the filesystem is case-insensitive, it reports that the case-changed new name already exists, which causes the behaviour that you encounter. Try a 2 step rename (with a temporary name), then commit, or changing it on a non-windows (technically on a case-sensitive filesytem) computer.

Update file with Git on Windows

I recent installed Git and I'm trying to update a file using this command:
(On windows 7)
git add Probe.txt
But it says "fatal: pathspec 'probe' did not match any files"
I'm in the directory which the file is. In fact, if I try git status I get "modified: Probe.txt".
How should I update my file?
try git add . which will add everything. Not sure why the specific filename isn't working, but this definitely should.
Looks like you're actually entering a space after "Probe" for some reason, observe:
~% cd /tmp
/tmp% mkdir foo
/tmp% cd foo
foo% git init
Initialized empty Git repository in /tmp/foo/.git/
foo% git add probe .txt
fatal: pathspec 'probe' did not match any files
foo%
I'm not on Windows at the moment but I think you can get the idea.
If you're pretty sure it's not the case, please re-try your command after setting
set GIT_TRACE=1
and update your question by the output of git add Probe.txt so we could guess further.

Resources