`git add` doesn't add files to track on Windows - windows

I have a local folder which I wanted to convert to a Git repository and then push to a remote repository. I ran the command git init in the project folder and then used the command git add .. When I run the command git status, I get the message that I have untracked files. I ran the git add . command multiple times but I see the same message.
What should I do to track these files so I can push to a remote repo?
I'm using Windows 8.1 x64 machine.
UPDATE: Please see the answer below.

I used the command git config --system core.longpaths true to fix the error for longer file names. I was able to add all files after making that change.

Related

pre-commit hook not working in macOS but working in Ubuntu

I have a git pre-commit hook script to validate certain thing during commit.
This in my script .githooks/pre-commit
#!/bin/bash
echo "Here I am!"
This is the file permission
In ubantu when I am committing anything I am able to view the echoed message, where as when I doing the the same thing in MacOS I am getting this error
fatal: cannot run .githooks/pre-commit: No such file or directory
git config is .git/config
line break type is CRLF
Also when I am directly running the file (in MacOS) from CLI like this, it is giving me the desired output.
./.githooks/pre-commit
My git version is 2.32.0 (Apple Git-132)
could you please try this and see if it's working for you?
brew link --overwrite git
brew update git
You should have the latest version of git -> 2.35.x
Now go to your local repository, i.e. the project folder, and then to the .git/hooks directory under your project folder.
You can place your hook files here. I.e. for pre-commit, the file name should be pre-commit (without any extension).
This should work whenever you try to commit to that specific repository. The main problem in your case seems to be the directory. The hooks should be in the .git/hooks directory of the project folder.
See the screenshots below.

Copy a project from Windows to Ubuntu in a way that git is recognized

I have copied a project (which was initialized with git and so contains a .git folder) from Windows to Ubuntu. If I now open the project on Ubuntu, VSCode tells me:
The folder currently open doesn't have a git repository
If I run git status, I get the following output:
fatal: cannot chdir to 'C:/Users/.../my_project': No such file or
directory
What is the right way to copy the project with a relative path, so that it can be recognized by other systems?
It is possible to package files and their history in a new local .git file:
git bundle create MyProject.git HEAD
Then you can copy/send the file from a Windows machine to Linux machine and clone it over there:
git clone MyProject.git /path/to/clone
And then e.g. add the origin remote:
git remote add origin https://dev.azure.com/path/to/_git/projectname

Can't commit update-index on Windows

I have a executable file called post_deploy that's run on my OpenShift gear after a push, but it wasn't executable so I ran:
git update-index --chmod=+x .openshift/action_hooks/post_deploy
But every time I did a git add to commit the file, the file would loose the executable permission. If I tried to do a commit, git would tell me there was nothing to commit. I eventually had to pop over to Cygwin to get it to work, but how can I get this to work in Window's Command Prompt?
Check your Git version: with Git 2.9.1, you can add with chmod
git add --chmod=+x -- yourFile
Also check the value of git config core.filemode. I suspect it should be false (which is expected in an environment which does not support executable bit).
Still, the add --chmod=+x should be enough to record that executable bit in the Git repo.
Finally, clone your repo in a Linux/Cygwin environment and check if the file is not already executable there.
The OP NicholasJohn16 reports below using "How do I remove files saying “old mode 100755 new mode 100644” from unstaged changes in Git?" to solve the issue.

ReadMe file won't allow me to commit and push xcode changes to github

I have an existing xcode project and repo on Github. I recently added a ReadMe file which was suggested by Github but now I can no longer commit and push changes to Github. I keep getting an out of date message. How do I fix this problem?
I had the same experience of adding README.md with the same error.
If you don't want to git pull, because the remote version in Github is outdated.
You can also force push all local branches using:
$ git push -f origin master
The following commands in the Terminal will push your local Xcode project to remote Github.
cd <drag location folder of project>
git init
git push -f origin master
You need to git pull.
If you're using the command line, navigate to the directory of the repository and run git pull. If you're using another interface, the steps may be a bit different.

Git config values clash

I ran into big git configuration problem on my windows laptop. I downloaded Git for Desktop since I wasn't able to install git lfs to my cygwin git. I then removed the git from cygwin. I have a GitHub project which is using git-lfs for storing
large files. When I clone the project and it starts downloading files from the remote server it says:
WARNING: These git config values clash:
git config "http.sslcainfo" = "C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt"
git config "http.sslcainfo" = "/ssl/certs/ca-bundle-ghfw.crt"
Neither of those file locations exist on my computer. When I use git config --list I can see both values for http.sslcainfo. But the mingw one is not listed in with any of the git config --system --list, git config --global --list or git config --local --list. So I can't locate the file where
configuration is. I assume the Git for Desktop wants to use the /ssl/certs/ location since it sets it to git config --system when it is installed. I also have installed mingw on my computer but I couldn't find .gitconfig file inside it. Also I don't know why git would even look from there or where the configurations might be saved. I'm able to clone repository which doesn't use git-lfs. So is there any way to remove the http.sslcainfo = "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt" configuration? Any help will be highly appreciated.
first of all, i have to tell you that im not sure if i can help you. However, i want to share my information with you.... maybe it helps. I am tying out git-lfs for some big repos at the moment. I am using the bitbucket test server. Atleast on bitbucket, they say that files from git lfs are downloaded via HTTPS and need an ssl cert.
I hope that this helps you a bit. If you got more questions about this, feel free to ask.
Frossy

Resources