I am working in Ruby and want to ignore my config files when I pull from Github.
The error I am receiving is:
"error: Your local changes to the following files would be overwritten by merge: config/database.yml"
Things I have tried:
1) I added the file paths to my .gitignore located in my application root.
2) I added the file paths to my global .gitignore
3) I ran git update-index --assume-unchanged /config/database.yml from my application root
4) I ran git update-index --skip-worktree config/database.yml from my application root
I have multiple instances of the same application in several different folders on my computer. The other instances of the application respect the assume-unchanged command. Im not sure what I am missing.
Consider stashing your local changes before pulling:
git stash
git pull
git stash pop
It is possible that you have merge conflicts if the files you are stashing are changed on the origin.
Related
Help!
I implemented Git to my project and somehow Git has made 3 files for saving my information: (1) Saves all of my view controllers, (2) The same file as (1), (3) my pods only.
The one containing my pods seems to be broken as I can not commit anything to it. First I thought nothing of these 3 Gits and proceeded coding, but now I am trying to branch my master with something I have been spending months coding but it seems to be crashing every time because it does not save my code to the master and makes me update my pods. Now after I tried to branch it, it did not work but now when I try to commit my files to the current branch I'm working on, it is not letting me without committing all 1600 files that are in my Pods. But the Pod file will not commit! I have no clue how to fix this and I am in desperate need of help!!!! Can anyone please help. I just want to have one place that will commit my files like in every Xcode git file. I do not want to lose my months of work.
I get the error: "The working copy “Pods” failed to commit files. - The source control operation failed because no repository could be found."
Please trouble shooting you issue with below aspects:
1. Use one git repository
If you mean 3 gits are 3 git repositories, you should keep only one git repo to manage your project. Only keep the repo that can contain all the files you want to manage under it’s directory.
As below example, if you project (the files you want to manage in git repo) is under Dir2 (not contains it’s parent Dir1), then you should remove the other two repos for Dir1 and Dir3 by removing the folders Dir1/.git and Dir1/Dir2/Dir3/.git.
Dir1
|___.git
|___ …
|___Dir2
|___.git
|___ …
|___Dir3
|___.git
|___ …
If you mean 3 gits are 3 git branches for the same git repo, before switching branches, you should make sure the work directory is clean (save and commit changes before switching branches).
2. Mark sure user.name and user.email has already been set
You can use the command git config -l to check if the output contains:
user.name=<username>
user.email=<email address>
If the output does not contain user.name and user.email, you should set as below:
git config --global user.name yourname
git config --global user.email xxx#xx.com
I have a problem where a Windows file restore changed the case of some file names. This causes a trainwreck with some projects.
Fortunately these projects are pushed to remote git servers. The remotes are up to date with origin/master, and cloning the projects is a solution. The only problem with that is the time-consuming task of replacing git-ignored files and dealing with other updates.
An ideal solution would be to pull down all files from the remote, overwriting the files in the origin/master. Is this possible? How do I force a pull down or merge, even though they are already a match. I want to keep it that way, just use git to rewrite the correct file name cases.
git pull or git pull -f results in Already up-to-date.
First, set git to be case sensitive. By default this was set true to match Windows:
git config core.ignorecase false
Check the list of changed-case file names Windows messed up. At the very least, this is your list of files to fix:
git status
Now, delete the files and folders that are messed up. Do not delete git ignored files! Files in .gitignore must be fixed the hard way.
Now, get your deleted files back as they were before Windows changed the case:
git checkout .
Yet another reason to quit Windows.
This morning my Windows 10 crashed and rebooted once I lifted my laptop's screen. No special activity was progressing, so I don't think there was significant disk activity.
However one of my main Git repos crashed after that reset. Here is what I tried:
$ git status
fatal: Not a git repository (or any of the parent directories): .git
$ git init
Reinitialized existing Git repository in ....../.git/
$ git status
fatal: Not a git repository (or any of the parent directories): .git
Loop
I don't think I have unpushed commits, so wiping and cloning from remote should work.
Still, can I ask what to do to recover an existing Git repository (.git directory still exists, chkdsk reports OK) in such cases?
[Add] read this but did not apply to my case (I can't restore the repo)
As kabanus said in a comment, you should definitely save whatever you can before proceeding (and/or use some other existing clone as a backup).
When Git complains about this, though, it often means that the file .git/HEAD has gone missing. If you create a new HEAD file with contents: ref: refs/heads/master, Git may be able to recover everything.
Since HEAD is the most active file in the repository, it's the one most likely to be clobbered by an OS error or power failure. It's also a critical file when it comes to whether Git believes a .git directory is a repository: if the directory contains a file named HEAD (along with a few other key items), it is a repository; if not, it is not a repository.
I had multiple branches corrupt due to OS error (bloody windows sleep function!!). So I had to manually do the following:
.git/HEAD (set content to ref: refs/heads/master)
$> git branch -v (this will tell you all the corrupt branches)
.git/logs/HEAD (Read the file for last checksum of the commits and merge of corrupt branches)
.git/refs/heads/{corrupt branch file} (change the checksum to the last working checksum from the log file.
merge the branches again as per need.
Another workaround for this, Solved for me while OS crashed on GIT MERGE operation
Get the working HEAD,FETCH_HEAD files under .git/ directory(of your project) from some other contributor
Replace the existing HEAD,FETCH_HEAD files with new ones(taken from other contributor).
Delete the INDEX under .git/ directory.
Then Do a git pull.
In my case, the HEAD file was indeed corrupted due to a system crash.
I just cloned the repo again into a new folder, switched to the branch I was in, then replaced the .git folder with the one I just created from the clone.
From there, it was like nothing happened.
In my case, The ownership of the repo was mismatched after OS reset.
I tried #raheel-hasan's instructions, after entering git branch -v command I got a suggestion.
git config --global --add safe.directory 'direactory path' this command solved the issue :)
(Use powershell to run this command)
You shoult reload your IDE or code editor after running this command.
I've got a series of HTML pages and other files for a website hosted on heroku sitting under a folder named 'sitename' on the User level of my computer - Windows 8 64 bit (that is, the files are in 'C:\Users\Me\sitename'
I'm trying to deploy them to the site using this code:
$ git add .
$ git commit -am "make it better"
$ git push heroku master
When I execute '$ git add .', the console starts returning tons of messages naming certain files and saying 'The file will have its original line endings in your working directory. warning: LF will be replaced by CLRF'.
Reading the question here, I found that it probably wouldn't affect anything in my code. However, when I run the code, it doesn't just affect the files in my git repository (which I think is set up correctly by running '$ git init', which creates a .git folder on the same level as the sitename folder), but starts to affect files in my AppData folder, e.g. iTunes.
Is this expected behavior? Will it affect anything? And is there a way to direct 'git add' towards only the repository?
I would recommend investigating where your git folder really is for your project first. Because it seems like you have somehow added files from the Appdata folder to your project, this indicates that the git folder you have created is not seperated from the other folders on the server. For example you have your git folder in:
'C:\Users\Me' instead of 'C:\Users\Me\sitename'
To easily see what files that have been added to your git project/Hasn't been added you can execute the command:
git status
This will also show your current staged files and if you have commited something.
To add single files/folder just write:
git add example.html
Where example is the name of the file you want to add (it can be any extension).
To remove files just do the same but use git rm.
trying to find an answer to this, have seen it hinted at, but no solution.
Not entirely new to git, but haven't used it in a few months... this is my first time using it on windows. using git bash.
I have a cake PHP site that I want to add exluding any cache files my .gitignore file contains only:
app/tmp/*
Here is the most basic thing I have tried:
git init
git add .
git commit
I get a message on commit saying there are untracked files - all files and dirs at the root directory.
git status
gives me the same message.
However, if I type
git add .htaccess
it stages the .htaccess file.
Also, if I do:
git add app/.htaccess
It will add that file too.
I have also tried
git add app/*
no luck.
Thanks in advance.
The files aren't ignored, because otherwise you would be forced to do a git add --force afile.
However, you might want to check GIT_DIR and GIT_WORK_TREE environment variable, and see if they reference another repository, which could explain the discrepancy between the index and what you think is your working tree.