I recently started using git-svn, and tried to tell Git to ignore any files that the Subversion repo ignores (mostly binaries and object files), by running "git svn show-ignore >> .gitignore"
Then I ran git status, and saw that many of those files that are now on my .gitignore list, are still showing up under "untracked files". Why? What do I need to do to fix this?
Or am I going about this the wrong way? I just want to be able to run "git add ." without it adding in all that junk to the commit.
Thanks.
If you already imported those files in the Git repo, they won't be ignored until you git rm --cached them.
You need to remove those file from the Git index (hence the --cached option), before seeing the .gitignore working.
Related
So I recently uploaded my react-native project on GitHub, then cloned it back to see how it will build(did it for first time... yeah). And on react-native run-ios I got a repetitive error: "react-native-app/ios/Pods/Target Support Files/Pods-testAppTests/Pods-testAppTests.debug.xcconfig: unable to open file (in target "testAppTests" in project "testApp") (in target 'testAppTests' from project 'testApp')
I found a solution, where this:
cd ios
pod deintegrate
pod install
helped me as the project then built and ran correctly.
So my question is, how to upload it to GitHub in a way so it builds always correctly after cloning it?
Update
Checking and editing .gitignore solved this problem.
Maybe this is linked to files which have been added/committed, while they should have been ignored, private and local only (not uploaded to GitHub)
Check your .gitignore: here is one for ReactNative, as explained in "Creating a .gitignore for a Clean React Repository", blog post written by Parker Johansen.
Then, assuming you don't have any pending changes/work in progress, you can, as explained here, apply your new .gitignore to your existing repository:
cd /path/to/local/cloned/repo
# create your .gitignore
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
git push
Finally, clone it again, and see if it compiles better.
The OP adds in the comments:
I found that folder 'Pods' doesn't exist on GitHub, that's why this error occurs, how can I add it to my /ios folder on Github correctly
I advise to check if there is a .gitignore rule which would ignore said folder:
git check-ignore -v Pods/aFile_inside_Pods
I am adding Conan support to my CMake projects. I followed Recipe and sources in the same repo tutorial and I end up with the expected package. Exploring the local repository folder, I found out that my source files are copied in 3 different folders (source, build and export_source) so the repo is growing fast even with small projects.
Is there a way to clean repository folders where sources are duplicated, after package creation (keeping only the folder needed for "dependency build from sources")?
Sure, you can remove things from the cache with the conan remove command. In this case you probably want to do:
conan remove "*" -s -b -f
* to match all packages in your local cache
-s to remove the source folders
-b to remove the build folders
-f to not ask for confirmation
The sources stored together with the conanfile.py in the cache, can't be removed, cause they are stored with the conanfile to be able to rebuild from sources when conan install --build is done.
I have added the .idea files to my .gitignore file and that seems to work fine. Since my .idea files were tracked already, though, earlier posts have suggested the following code, to get them out from under version control.
git rm -rf .idea
or
git rm -r --cached .idea
In either case, though, I get the message:
fatal: pathspec '.idea' did not match any files.
When I list my files in this folder, though, .idea is right up top.
What am I doing wrong?
fatal: pathspec '.idea' did not match any files.
assuming there would be no file with the name .idea on the path
Since you are trying to remove the entire folder change your command
git rm -r --cached .idea
to
git rm -r --cached .idea/
For different changes I made in my project, I need to restart Git repo and start with a new fresh version with the current project. How can I achieve this?
Many thanks
fire up your terminal:
go to project
cd myPath/MyProject
delete the current repo on your disk - your git repo = RIP
rm -Rf .git
init a new repo
git init
add your project to the new git repo
git add .
commit
git commit -a -m "init Project XY"
check if the repo is o.k
git status
What you want to do is create a new empty branch without any history. That way you start fresh but still have the option to return to your previous content. Inside the git repository, enter these commands:
git symbolic-ref HEAD refs/heads/<branchname>
rm .git/index
git clean -fdx
After that you are in the same situation as with an empty repository (i.e. start adding and commiting files) except that the history still exists in your old branches.
Note that all files you don't have in your old version will be permanently removed.
I am using a new red hat os, with git version 1.7.6 (also tried 1.9.2). I also have a debian 6 machine with git 1.7.6. When I create a clone and populate a submodule on the debian machine, the submodule ends up with a .git directory. However, when I perform the same commands on the red hat machine, my submodule ends up with a file named .git, and a new directory under my root repo in .git, named modules. This modules directory appears to contain the contents I would expect to be in .git under the submodule. What is going on???
Yes, it did change in git 1.7.8, to make checking out commits across the introduction of submodules easier.
See https://raw.github.com/gitster/git/master/Documentation/RelNotes/1.7.8.txt near the end of the Updates, above the fixes.