Update file with Git on Windows - 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.

Related

Git for Windows "No tags file" Response from "git diff" Command

Git version: 2.14.2.2
Whenever I run git diff on a repository I am greeted with the response No tags file. I have tried running the command on multiple repositories, multiple consoles (Cmd, PowerShell, MINGW64, Visual Studio Command Prompt) and all have the same response.
Strangely, the git log command also fails. Many other commands work, however, such as git status, git pull, etc. It seems to be only log and diff.
I have uninstalled Git entirely and reinstalled. Restarted my system. Tried referencing the git.exe directly (which yields the exact same response). Nothing is working and I have not seen this error anywhere else. I compared my user configs with those of a colleague and they are identical.
Some portion of the command executes properly, because if I supply two commit hashes, and I intentionally break one, the response I receive is:
It seems like another program may be hijacking the git diff command. I believe this because I'm not sure "No tags file" is even a possible Git response. Not sure what else it would be.
To make things even more confusing- my ultimate goal is to run the git diff within the context of an msbuild and it DOES EXECUTE CORRECTLY. Now, I could be satisfied with this, but I need to modify the diff command slightly, and running a full build each time is not productive, nor easy to troubleshoot. There is a task within the build script that runs an Exec command and it has no issues performing the diff. I'm also able to execute a Diff Against Current within SourceTree, which to the best of my knowledge, runs a git diff behind the scenes.
Any help would be very much appreciated.
:: Edits ::
Various commands:
git diff HEAD~1 HEAD
git diff master~1 master
git diff <commit-hash-1> <commit-hash-2>
git log HEAD~1..HEAD
git log master~1..master
git log <commit-hash-1>..<commit-hash-2>
Output:
Every one of the commands above returns the same No tags file response, in all of my repos.
Cat Head:
cd .git
cat HEAD
ls -R refs
Output:
New Repo:
mkdir testrepo
cd testrepo
git init
echo "file1" > file1.txt
git add .
git commit -m "initial commit of file1.txt"
echo "Hi there!" > file2.txt
git add .
git commit -m "added file2.txt"
git log
git diff HEAD~1 HEAD
Output:
git config -e:
git config --global -e:
::Edits 2::
I uninstalled all of my diffing/source control tools (SourceTree, Git, SVN, WinMerge, KDiff). Installed the portable version of Git. Opened CMD to a repo, put in full path to the git.exe portable and it still returned the No tags file response.
I also reviewed all of my path variables for: git, vim, ming, mintty and anything else that seemed suspect, but didn't find any.
I have restarted after performing all steps, and yet the problem persists.
::Edits 3::
I have a different user on my laptop, switched to that user and the git diff works properly, so clearly there is something with my main user that is conflicting. Will continue to look into my User directory for issues.
Here are the steps I'd take in this situation:
Try the following and check the response:
git diff HEAD~1 HEAD
git diff master~1 master
git diff <commit-hash-1> <commit-hash-2>
Try the same with log:
git log HEAD~1..HEAD
git log master~1..master
git log <commit-hash-1>..<commit-hash-2>
I'm actually guessing that your refs are messed up, which means that the direct hashes might work, but the HEAD and/or master one may not.
Look into the .git/refs folder
From the main repo folder:
cd .git
cat HEAD
ls -R refs
Hopefully, HEAD is pointing to a branch, and if master is checked out, cat HEAD output should look like:
ref: refs/heads/master
Then, the ls -R refs, should show a heads folder, with files for each of your local branches (i.e. master and possibly others). You also likely have refs/remotes and refs/tags directories.
If any of these things are radically different or missing, that could be your issue...
Since you have reinstalled git, create a brand new repo and try the same commands:
mkdir testrepo
cd testrepo
git init
echo "file1" > file1.txt
git add .
git commit -m "initial commit of file1.txt"
echo "Hi there!" > file2.txt
git add .
git commit -m "added file2.txt"
git log
git diff HEAD~1 HEAD
If this last one works, then git is likely working okay, but some tool you have is messing things up.
Post your config from git config -e and git config --global -e - maybe we can see something?
When googling for the "No tags file" message, the first results I get all talk about vi.
I do not understand why git would try to execute vi when running git diff or git log, could it be that your system is configured to use vi as a pager ?
# some possible places which could influence that :
echo $PAGER
echo $GIT_PAGER
git config --get core.pager
When digging in the documentation for less, I found that less can use a ctags file, to spot "the file that contains this tag".
So you can also look at the list of variables that influence the behavior of less :
# from bash :
# env will list all the defined environment variables
env
# the ones that impact 'less' should contain "LESS" in their names :
env | grep LESS

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.

git-svn fetch gives me a filename that git doesn't handle

Using git svn fetch to do some local work (using git personally), I got a file that will not "reset". I see that it's different from similar files in the same directory in that it has a backslash as part of the name: icon#2xios8\.png. I suppose the backslash doesn't do anything on other platforms but msysgit on Windows 10 complains that it's unable to create the file.
I can't figure out how to make git ignore this subdirectory and let me continue with unrelated work. But I really need to fix it somehow so git can be used.
You can do this with git-read-tree and sparse checkout (git-read-tree).
Therefore you call
git config core.sparsecheckout true
Then create a file .git/info/sparse-checkout (with touch .git/info/sparse-checkout in msysgit bash). Edit this file and change its content to:
/*
!icon#2xios8\\.png
This tells git to look at all files in your working directory (/*) but '!icon#2xios8.png' (!icon#2xios8\\.png). Notice the escaped backslash here (\\)!
After you run git read-tree -mu HEAD you should be able to pull your repository by ignoring that specific file.

Git-bash tab completion: "fatal: Not a git repository: '.git'" (Windows)

I'm using git on windows with the git bash and every time I want to autocomplete a filename in a git command I get fatal: Not a git repository: '.git' posted between my already typed characters and the completed ones.
It looks like this:
$ git diff a
<using tab>
$ git diff afatal: Not a git repository: '.git'
pp.js
I can still make the command properly by just pressing enter as expected. But it really starts to get on my nerves.
Any suggestions?
The problem was an extra .git-folder in my src folder. The repository was initialized on the folder above (src/..) and this seemed to mess with git. After the removal of the extra .git folder the problem disappered.
I just discoverd the solution. I had an extra .git directory in my src-folder which seemed to mess with git (the repository was initialised on the folder above).
After I removed the extra .git folder the problem disappered.
It can depends on the msysgit version you are using:
I just tested a tab completion on a git diff on W7 64bits, with the latest msysgit1.8.3, and it worked just fine.
Don't forget that, in addition to the msysgit version, you will have issues with tab completion due to the old bash 3.1 included in mysysgit.
And the completion can be slow on Windows.
As the OP Zeeker mentions below, the completion git-completion.bash is based on a proper git repo path detection.
# __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo
__gitdir () {
...
}
And in Zeeker's case, an extra .git folder was in the src folder, which means any completion was based from the wrong folder, which, for git diff, proved fatal.
git add seems to work though.
git-bash completion for git commands is controlled by the /etc/git-completion.bash. To fix run git-bash as administrator, then:
cd /etc
mv /etc/git-completion.bash /etc/git-completion.bash.orig
Then create a new one from the contents of https://github.com/git/git/blob/master/contrib/completion/git-completion.bash

Xcode and Git Source Control : "The working copy XXXXX failed to commit files"

I know this may be an ultra-newbie question, but - although I've been coding for like 18 years - it's been only a few days that I've been using Source Control for my project and I feel quite lost.
I have set up Git properly and, from time to time, I'm commiting the changes.
(File -> Source Control -> Commit)
However :
Whenever I try to delete a file (that initially existed) and then commit the changes, I'm getting an error like this :
The working copy "MY_COPY_NAME" failed to commit files
fatal: could not switch to "/the/path/of/the/file/i/just/deleted": no
such file or directory
What's going on?
What should I do in order to commit the changes even after a file has been deleted?
you should run
git add -u your_file
the -u means you want to update the file you already added. Another possibility is
git rm your_file
And it's likely you get an error if Git does not find an inexisting
To fix above error you should use below lines of code:
Open the command line [Terminal] and enter the following two commands:
xcrun git config --global user.email your#Email.com
xcrun git config --global user.name "Enter Your Name"

Resources