1

I am one of the developer of ruby on rails project both three of us have different database configuration. My question is how can i ignore database.yml file and prevent it of being pushed to the repository.I tried to add it in the .gitignore file and put a line their like this

 #ignore database connection
  /config/database.yml

but when i use git commit -am "my message" and then git push --all but then the database.yml file is also push to repository.can someone give me some tips on how to use git in a much efficient and faster way,because i always use git commit -am "my message" then git push --all to push all my changes but if i do this database.yml file will also be pushed to the repository.Since i am new to git i dont have much experience on using this since no one really give me explainations on the proper way of using git.

jameshwart lopez
  • 2,993
  • 6
  • 35
  • 65
  • @meagar Why did you post an answer only to later mark the question as duplicate? – Tim Biegeleisen Jul 17 '15 at 03:09
  • oh my God i lost new idea. i was waiting for the proper pushing to git..on what should i do – jameshwart lopez Jul 17 '15 at 03:11
  • What is your question? Just view the duplicate link given above and you should be good to go. – Tim Biegeleisen Jul 17 '15 at 03:13
  • im asking to prevent the file from getting pushed then after that what should be the proper way of commiting and pushing – jameshwart lopez Jul 17 '15 at 03:14
  • This doesn't sound like a good plan. Do you or do you not want the file to be part of your version control? – Tim Biegeleisen Jul 17 '15 at 03:17
  • @TimBiegeleisen I misunderstood the question. It wasn't the use of `-a` that was the problem; it was attempting to add an already tracked file to `.gitignore`. – user229044 Jul 17 '15 at 03:19
  • the reason why i ask stop pushing the databases configuration file is that if i push to git and one of my colleage pull data from the repository my database configuration file will be his new configuration file instead of his own configuration file.Thats why i ask what should be the proper way of commiting and pushing the file.Since i am one of the developer sir.And sir i also mention that im new to git thats also the reason why ask proper way of doing it ,since i dont have proper education of doing it sir – jameshwart lopez Jul 17 '15 at 03:21
  • It wont be a good idea to add database.yml to gitignore .. you should only add generated files to git ignore..what happens when you actually want to change the file..that would be too much work..since this is a yml file you can write a solution using it...i would hint using $USER..your choice though – sethi Jul 17 '15 at 03:32
  • @sethi then sir what should i do ,because we had different dabase configuration?in every time i git pull then my database configuration will also change my local project would be messed up.. that's why ignoring it, both the three of us might be a good solution , but then how would i be commiting and pushing – jameshwart lopez Jul 17 '15 at 03:43
  • @jameshwartlopez your yml supports ruby code ... so you can try something like following but not exactly...here I have tried using a different sqlite database depending on the username...you logic can be different but you can write some logic to pick different dbs for each of you -> development: <<: *default database: <%=ENV['USER']%>.sqlite3 – sethi Jul 17 '15 at 03:57

0 Answers0