New files aren't showing up only folders - windows

I'm relatively new to git. I'm using:
git version 1.8.1.msysgit.1
Powershell & Poshgit
I've added one new folder and one new file to my repository. When i do a git status i see the folder but not the file. Why?
In the untracked folder you see there is 1 .sql file and yes i'm sure its not in .gitignore (i've changed .sql files recently and they were tracked).
If i do a git add . will the file that is not shown be added?
Update:
I just had to add the directory and the file automatically shows up. I'm assuming if i had multiple files all of them whould show up. See the command i executed below:

git status is reporting that you have an entire directory without any files that you have git added. As soon as you git add one of the files inside the directory, it will list them.

That's a simplification of git. It knows that it doesn't track any file in that folder, so it just shows the folder name instead of all files it contains.

Related

Why are subfolders not being seen by the Git repository?

I have just created a local repository (using Git) for a project that will contain many subfolders (it is a pedagogical project with Lesson 1...2...3 etc..., each one with a folder within the main directory).
I connected this to the remote repository I created on GitHub.com and hoped that would have been enough to start working, pushing, committing etc... now that I have created the first Xcode project inside the main folder neither Xcode Commit function nor Terminal git commit command is seeing any change.
The symptoms I see are that the remote repository sees "Project name" folder, then "Lesson 1" folder inside it but nothing else inside "Lesson 1", where the Xcode project should be (it actually is there in the Finder).
What may have gone wrong?
What would have been the proper set of actions to create a repository in a directory that would automatically fetch every new file added to it?
Thank you so much!
Git will not automatically track new files you create in the directory tree which contains your local git repo.
When you create new files, you need to inform git that you want them tracked, with the "git add" command.
git add path-to-new-file
If you create new files and do not add them, then when you run the "git status" command the output should contain a section labeled Untracked files, like this:
Untracked files:
(use "git add ..." to include in what will be
committed)
asdf.txt
It will show the path to the file(s) relative to the top of your git repo, including the filename(s). Pass all of that to the git add command. Then commit, just as you would for changed files.

How to enable .gitignore file in private repository in GitHub with GUI

I can't uploud a project in private repository even I'have .gitignore file(where I made a mistake, because .gitignore doesn't work). Message is that I have more than a hundred files, and simply I can't uploud it in one piece, just one by one folder or file.
I have make a new private repository in GitHub, and at the start of making it's offering to make a gitignore file, so I done that step(I chose a Visual Studio gitignore file, and then I put all files I don't need, even a whole folders I don't need from my project I've made in VS). But problem is in uplouding folders after I make the repository. Every time I try to uploud it, I get a message that I have more than a hundred files. I've even opened a whole new private repository in case git alredy tracked the files in this one. And it seems nothing is working. I have reed all official documentacion about gitignore files in GitHub, I've seen a bunch of Youtube tutorials and tryed to make a gitignore file direct in VS but also doesn't work.
Maybe it's seems funy to most of you and it is probably a banal mistake but I just can't figure this out.
SENCE I'M A TOTAL BEGINNER please can anyone tell me where I make a mistake?
Here is a piece of my .gitignore file, most of it is official code, and it is very big.
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
App_Data/
Content/
fonts/
Scripts/
*/favicon.ico
*/packages.config
I just want my whole project uploud it in one piece without unnecessary files from VS.
List item
I will augment #Harmonica141 answers by suggesting you to use on line .gitignore file generator.
After selecting desired IDE or programming language .gitignore file will be generated for you with all required regex and file exclusion.
After downloading a file you need to add it to the repository by command line.
Do as follows:
cd into/the/repository/folder
git add .gitignore
git commit -m "Added .gitignore."
git push origin
Your .gitignore is active as soon as it is tracked by git. To accomplish that, you will have to commit it. Do this first, make a commit consisting only of that file. Then git should not "see" all the files masked by it any longer.
In command line do as follows:
cd into the repository folder
git add .gitignore
git commit -m "Added .gitignore."
git status
The last statement should show you all the files that are still untracked or uncommitted but not the ones contained in the .gitignore. From there you can keep adding and committing as usual.
Don't forget to push later to have your changes up on remote.

git automatic add and remove?

so to add a file I need to run git add and to remove a file git remove
but this seems to be a very time consuming job if the project has a lot of files that change on my local copy and then the remote repo needs to be updated.
is there some automatic way to sync the local repo with the remote one, like in the GUI version of git? the gui vesion automatically adds new files and removes deleted files
You can use git add -A. It works on your entire working copy and stages (adds to the "Changes to be committed" section) all new (not ignored), modified and deleted files.
There are GUIs available that may help you add files in bulk. I have used Atlassian SourceTree with some success. However there are ways to add multiple files easily from the command line.
You can use wild cards to add multiple files (i.e. git add CurrentDir/*.c to add all the .c files in the current directory. There are more examples of using wildcards in the git documentation.

Why are these files not ignored by git?

My .gitignore file contains these lines :
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
But the following file is still tracked
/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
Why is it so? How can I fix that?
PS: If I had MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger, the files are ignored. But I don't understand why it does not ignore them without this "hack".
EDIT 1
Contrary to what is said in one of the answer, the pattern
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
works !!! I mean, the files under /xcschemes are tracked.
See also the post Git ignore file for Xcode projects, where I get this .gitignore file.
EDIT 2
My Git version is 1.8.3.4 (Apple Git-47).
EDIT 3
When I git check-ignore this file, here is what I get
fatal: Not a git repository (or any of the parent directories): .git
But the fact is that a parent directory is a git directory...
EDIT 4
When I git check-ignore --no-index -- this file, here is what I get
[MT] PluginLoading: Required plug-in compatibility UUID 37B30044-3B14-46BA-ABAA-F01000C27B63 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeSnippetsHelper.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2014-02-10 10:03:50.856 xcodebuild[1496:d07] XcodeColors: load (v10.1)
2014-02-10 10:03:50.859 xcodebuild[1496:d07] XcodeColors: pluginDidLoad:
fatal: Not a git repository (or any of the parent directories): .git
EDIT 4bis
From the root folder :
if I don't use the no-index option, there is no reply to git check-ignore.
if I use the no-index option: I get the error error: unknown option 'no-index'...
Strange ;-!
First, you can do a git check-ignore (git 1.8.3.3+) to see what rule is ignoring your file (assuming it wasn't in the index in the first place)
Second, read ".gitignore exclude folder but include specific subfolder":
It is not possible to re-include a file if a parent directory of that file is excluded. (*)
(*: unless certain conditions are met in git 2.8+, see below)
Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
So the file of xcschemes wouldn't be un-ignored anyway.
You needed to ignore parent folder per parent folder.
But a better approach is to ignores files only, and then exclude the folder:
xcuserdata/**
!xcuserdata/**/
!xcuserdata/**/xcschemes/**
Remember:
You need to exclude folders from the gitignore rules before being able to exclude files.
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
Nguyễn Thái Ngọc Duy (pclouds) is trying to add this feature:
commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
However:
The directory part in the re-include rules must be literal (i.e. no wildcards)
So that wouldn't have worked here anyway.
Adding file names to .gitignore helps prevent you from adding the files unintentionally.
If you do something like git add . to add a folder full of files to the repository, the files (or filetypes) ignored in .gitignore will not be added.
They would have to be added by using the -f flag with the git add command.
It will not change anything if the files are already tracked.
You can stop tracking the files by using the answer to the question:
Remove a file from a Git repository without deleting it from the local filesystem
edit: After rereading the question a few more times, I think you may be having roughly the same issue that was addressed in this answer:
.gitignore - ignore any 'bin' directory

change svn working copy to another directory

Q: So I have local svn setup on my mac. I want to change to working copy of a repository to another folder without 'svn checkout', so that I can commit some code that is not currently in the working copy.
Problem with 'svn checkout'
The reason I don't want to use 'svn checkout' is b/c I don't want to overwrite the code into the new folder designated for working copy, because when I move the new code into the new designated folder and do an svn commit, I get an error based on the .svn hidden folders that svn attaches to your committed code.
What I am trying to accomplish?
I got myself into this mess, b/c I am trying to add multiple versions of my code into different folders, so that I can compare them against one another.
Thanks, Jon
You can use "svn copy" to copy one or more files in a working copy or in the repository.
More details: http://www.visualsvn.com/support/svnbook/ref/svn/c/copy/
I hope it helps.
When you do a svn checkout, it does not delete and overwrite existing files - it merges them (try it - make a backup copy of your target directory and then svn checkout into it).
However, the simplest way is to svn checkout into a clean directory, then copy your files on top of the checkout. Rename your current directory to something else if you need to keep the directory name for your checkout.

Resources