Sunday, June 29, 2014

How to set GIT to ignore a few files - like properties or config files


From time to time there are files you don’t want git to track. There are a few methods of telling git what files to ignore.

Method One:
1.      Create a .gitignore file in your git repository home.
2.      Create rules inside the .gitignore file.
Examples:
# To ignore a ‘build’ folder
build/
# To ignore all ‘.class’ files
*.class
            We can use this method to ignore the folder/files that are specific to project (common to all users).
It can be pushed to central repository, so that all users can use the same .gitignore file.
Note: This method can not be used to ignore the files that are already tracked by GIT.

Method Two:
1. Create rules inside .git/info/exclude file.
Examples:
# To ignore a ‘.project’ and ‘.classpath’ files
.project
.classpath
This method can be used to ignore locally-generated files that you don’t expect other users to generate, like files created by your editor.
These rules can not be committed with the repository, so they are not shared with others.
Note: This method can not be used to ignore the files that are already tracked by GIT.

Method Three:
1.      Use --assume-unchanged.
                    git update-index --assume-unchanged <filename>
Example:
      # To ignore build.xml, run this command.
                        git update-index --assume-unchanged build.xml
Note: We can use this method to ignore the files that are already tracked. To track the file again, 
execute "git update-index --no-assume-unchanged <filename>". These commands do not affect remote repository.

Friday, June 6, 2014

Types of GIT Branches..

1. Remote Branch
         The branch which exists in the remote repository. This will be updated whenever you do git push.
2. Local Branch
         The branch which exists in your local repository. This is where you make code changes. This branch will be updated whenever you do git commit, git merge and git pull.
3. Remote Tracking Branch
          The copy of remote branch, exists in the local repository. The intermediate branch between your local branch and the remote branch. This branch will be updated, whenever you do git fetch, git pull and git push.