Sunday, July 20, 2014

Using Winmerge as a diff tool in GIT


Step 1:
Install Winmerge.

Step 2:
Create a file named ‘winmerge.sh’ under your repository.

Step 3:
Write this into ‘winmerger.sh’ file.
#!/bin/sh
echo Launching WinMergeU.exe: $1 $2
"PathToWinMerge" -e -ub -dl "Base" -dr "Mine" "$1" "$2"
Path To Winmerge: Ex:  C:/Program Files/WinMerge/WinMergeU.exe

Step 4:
Update your .gitconfig file (will be under your user folder C:\Documents and Settings\YourName)
[diff]
            tool = winmerge
[difftool]
            prompt = false
[difftool "winmerge"]
            cmd = winmerge.sh $LOCAL $REMOTE

Step 5:
Using winmerge:
git difftool ReleativeFilePath/FileName

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.

Sunday, May 18, 2014

How to fix GIT error: You have not concluded your merge (MERGE_HEAD exists)

GIT Error message:
You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.

Cause: Your previous merge was failed to merge automatically and went to conflict state. And you tried to pull again before resolving the conflict.
Solution: Undo the merge and perform the merge again properly.
Steps:
1) Undo the merge and pull again.
To undo a merge:
git merge --abort [Since git version 1.7.4]
git reset --merge [prior git versions]
2) Resolve the conflict.
3) Don't forget to add and commit the merge.
4) git pull now should work fine.

Please let me know, if it's still not working. Thanks.

Link to my SO post: http://stackoverflow.com/a/11647899/1365319