git pull says config/environments/development.rb is not committed - ruby-on-rails

Doing a pull from master into my local branch on a shared ROR project. Git says:
branch master -> FETCH_HEAD error: Your local changes
to the following files would be overwritten by merge:
config/environments/development.rb Please, commit your changes or
stash them before you can merge. Aborting
development.rb is not showing up as having been modified, and, in fact, when I actually do modify it, it still doesn't show as having been modified. This is happening on all branches, effectively preventing me from merging in master.
I should say here that I am a designer on this project and my ROR and Git skills are not huge (I have mostly been using the Tower GUI for managing branches). However, I've been successfully contributing to the project for over a year and never came across this issue before.

If you type 'git status' do you see development.rb in the list of untracked files? If so you need to 'git add' it and commit.
Alternately, in the root of your project look at .gitignore and see if it's listed in there for some weird reason. It shouldn't be, but it's worth looking.

My gut feeling that you are using git update-index --assume-unchanged development.rb, but don't remember it. If it is the case, use --no-assume-unchanged then.

It is hard to say without looking at your .gitignore but you could have config/environments/development.rb in that file, in which case you wouldn't see changes.
But that isn't the real issue, it sounds like you just need to commit then pull. This is what I would do.
Add config/environments/development.rb to your commit, commit changes then pull. If that doesn't work, I would just delete your local copy and clone a new one.
I hope that helps.

Related

Accidentally committed and pushed 'database.yml' to Rails Git Repo

I am working on a Rails project!
Excuse for not adding .gitignore
I have accidentally committed and pushed 'database.yml' in to my feature branch. A pull request was created from the feature branch to master branch a few days ago and is not yet merged. There are multiple commits done as part of this pull request and the commit containing 'database.yml' is the fourth last commit.
Others are also working as part of this project and they are merging the changes to master and we are pulling those changes in to our feature branch in-between. Thus, in our feature branch, we have got commits from others which are done after the faulty commit.
so I wish to do a 'git rm' and 'git push' the same file again to resolve this issue (as the PR is not yet merged). Will that create problem?
If you remove the database.yml that will be another commit on top, and nobody will be affected.
Notice, however, that the database.yml will still be part of the history and can be accessed via git log. If that file contains sensitive information, it will be findable by others.
Delete the file from your local system then add the changes to a commit using
git add <FILE_PATH> command and then commit and push the changes and it should be fine.
The right way to remove it properly is to reverse the changes you made to the file and commit it.
Another, dirtier way, is to open the commit and remove the changes and force push it to the repo. But you need the proper rights for this. Others will also have problems if they try to pull changes then.

git-tfs clone and cleanup

I have cloned my TFVC from VSTS and it pulled all my branches without any errors. I then followed a number of online posts that said to cleanup my projects by doing the following:
Remove the GlobalSection(TeamFundationVersionControl) section from solution files
remove all *.vssscc files
Remove all *.vspscc files
When I do this I get almost all of my files showing up in the Changes window under Team Explorer. All of these files have no changes when doing a diff except for the files discussed earlier.
What is the proper way to cleanup branches after doing the clone from TFVC to git?
Thanks
If you want to migrate an existing TFVC repos to Git repos, you can use the git-tfs tool, which allows you to migrate a TFVC repo to a Git repo in just a couple of commands.
In my example, with the commands below, I have successfully migrated an existing TFVC repo to Git repo with all branches.
If you don't want to clone the branches, you can specify --branches=VALUE (VALUE=none|auto|all), check https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md
When I do this I get almost all of my files showing up in the Changes window under Team Explorer. All of these files have no changes when doing a diff
That should be due to a bad end of line setting...
except for the files discussed earlier.
First commit them...
Then fix your setting.
You've got 2 options (not mutualy exclusive, you could do the 2. But if you do only one, do the 2nd) :
(old style), set the git core.autocrlf setting. On windows, that's either true to convert all file to a windows eol style or false to tell git to not touch the files. It's a matter of choice. This settings will be used for ALL your repositories but will be personal
(new one recommended) Add a .gitattributes files to telle git how to handle eol for all type of files. This settings will be used for this repository only but will be shared by all the developpers and noone won't be able to commit bad files.
Be aware that for all the strategies that you will try, to be sure that it works, you will have to do soemthing special. You will have to wipe all the files and checkout them all from the repository (because that's at this special moment that git modify the files):
git checkout .
There is a possibility that in fact, the files are modified because they have been checkouted in the format you wish, so commmit them all (you will be obliged) and apply the eol strategy, just after...
A good doc on the subject that you should read carefully and understand before trying something...
PS: handling end of line is not an easy task in a git repository and it will take you quite some time and you will have to try a lot of things before really understanding how it works ( I'm not pretty sure myself ;) )

on git pull asking to commit the local changes

I am doing git pull, It says
error: Your local changes to the following files would be overwritten by merge:
Gemfile
Please, commit your changes or stash them before you can merge.
Aborting
I don't remember doing any changes to gemfile.
On git status nothing is shown apart from all the files that I have removed.
How can I fix it. And How can I remove all the deleted files being shown while I do git status.
Please help.
For this scenario you have to use git stash refer this link (https://git-scm.com/book/no-nb/v1/Git-Tools-Stashing)
Removal of files is also a change from the previous commit, so commit your changes by using first git add(the files you have edited, not sure about removed) then then git commit. After that, take merge, or,
You can also write git checkout gemfile before taking merge, if you are sure that you haven't made any changes to it. This will restore gemfile to previous commit. Then take the merge.

github is not the same after push

I'm wondering how this is possible.
I made quite a bit of changes to my rails project (deleted some stuff, edited files, added files, ...) as I implemented a whole new design.
And now I want to commit my project and push it to github
git merge new-view
git add .
git commit -am "implemented the new design"
git push origin master
Now when I pulled the changes on another computer I noticed that not all of my features were working. (for example the image slider wasn't functioning).
When I go trough the files, it looks like all the changes I made are there, but I must be missing something because both projects are not behaving in the same way!
Even when I clone the project again from github (on the original computer with the working projectfolder), the feature still doesn't work.
git clone projectname
Now in my old folder I can't push any other changes as status tells me that my branch is up to date with origin/master
git status
I figure that I can just delete the github project and upload it again, but that's obviously not the way this is supposed to be done.
Any ideas what could've gone wrong?
Make sure that no important files are being ignored- see this answer
Make sure everything is truly committed. git status and git status --cached
Make sure any databases are initialized, migrated and populated with the same data.
Check browser caching.

GIT deleted my local files

I have a pretty big problem. I am going through a Ruby on Rails tutorial, and they have suggested that I use GIT for version control. I have never used it before, and through the tutorial I don't think I used it right. Here is some back story.
I created a new project, and then I created a new Github repository. I named them the same thing, and I pushed my project to that repository. I then looked at Github, and all of my project files were there. I then went through a few chapters of the tutorial, and followed there instructions for pushing files to GIT. After awhile I realized, that none of my files were being uploaded. I didn't really care, so I went on with the tutorial. Still pushing files to GIT even though they were not showing up.
IMPORTANT
My Github repository only had the few files from when I first created it, the project on my local machine has a MANY more files. In the last chapter of the tutorial I was able to follow, it told me to do these commands:
$ git add .
$ git commit -m "Finish layout and routes"
$ git checkout master
$ git merge filling-in-layout
Once I did those commands, my project located on my local machine lost ALL of the files I created in the last couple of days. My guess is that Github replaced my files from my local machine with the files on Github (Just the files created when I started the project)
I think I have been adding files to GIT on my local machine since the folder '~/.git/logs/HEAD' has all of the commits I made, with what looks like GIT file numbers.
Any help would save me so many hours.
Thanks, -Chris
You committed some changes, then got the old version and reverted to it by issuing "git merge filling-in-layout". (you created a branch "filling-in-layout")
whatever you do DO NOT -> git reset --hard <- DO NOT.
what does "git branch" say?
do this:
git checkout master (or one of the others)
and look which one is yours. ;)
Erase github from your mind. It is irrelevant. The git repository is on your machine, inside your rails app folder. That is the beauty of git. So everything you have ever committed to git while working from that folder is there. It's possible you made some mistake along the way, or that the tutorial instructed you incorrectly, but you can look through all your commits with "git log", and then just go back to the point where things were good: checkout that commit (thus recreating the situation as it was at that moment), and pick up again from there.
Pedagogically I would suggest that you not try to learn git and rails simultaneously. They are both big and interesting, but they are completely orthogonal (that's fancy talk for "they have nothing to do with one another"). If you want to learn rails, learn rails. If you want to learn git, learn git. Just a suggestion.

Resources