Posts

Showing posts from May, 2011

How to set GIT (master or branch) to a previous commit version

First you need to switch to the desired location master or branch git checkout master or branch_name Then git push -f origin commit_id:mast er  (For master) git push -f origin commit_id:branch_name ( For branch) Then you also need to cancel your local commit git reset --hard commit_id (from the desired location)

How to Ignore certain files from Git commit (modified but never need to commit)

Sometimes we may need to ignore certain modified files from Git commit (Eg: config/database.yml). This can be done by issuing  the following command from your project path git update-index --assume-unchanged config/database.yml Or in case of folder git update-index --assume-unchanged folder-name/ In the case of a new folder or file (Not added to GIT before) we can ignore by adding it to .gitignore file Create a .gitignore file if doesn't exist in your project path Add the required folder or file path in it.            # Ignore bundler config              .bundle          # Ignore the default SQLite database.             db/*.sqlite3          # Ignore all logfiles and tempfiles.            log/*.log            tmp