Git commands
I like Git a lot. It is very much powerful then SVN. You can’t commit or merge if there are changes on same branch on server, this will prevent files to overwrite. See following statement.
To create branch, use following statement.
$ git branch branchNamebranchName is example in this post, you can give any name. If you run following command, you will see list of branches.
$ git branchFollowing is list of branches. branchName is that you created and the “master” branch is a default branch that was created for you automatically.
$ git branch branchName *masterIn above section * show current branch mean you are on master branch. To go on branchName , run following command.
$ git checkout branchNameNow make changes any git repository file. You can check changed files that you changed by following command.
$ git statusAfter this statement you will see file name with path where file exists. You must have to commit before switching branch, so that your changes can be save.
$ git commit -am 'message'Message can be any that remind you what changes you commit on any branch. Now checkout to master branch
$ git checkout masterNow you will see that your changes aren’t visible there. Merge branchName to master by following command
$ git merge branchNameIf your changes don’t conflicts, then you are done. If there are conflicts then markers will be left in the problematic files showing the conflicts and you will also see file name with paths in which conflict have in git prompt. You can also use following statement to find difference in branches.
$ git diffFollowing are marker that will come in the conflicted file.
{code type=code}
<<<<<<< HEAD Any statement ======= Changes >>>>>>> branchName
[/php]When you resolve conflicts you have to again commit these changes.
$ git commit -am 'message'Now your changes are merged.
More commands will be in next article