Misc.

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 branchName

branchName is example in this post, you can give any name. If you run following command, you will see list of branches.

   $ git branch
  

Following 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
     *master
  

In above section * show current branch mean you are on master branch. To go on branchName , run following command.

$ git checkout branchName

Now make changes any git repository file. You can check changed files that you changed by following command.

$ git status

After 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 master

Now you will see that your changes aren’t visible there. Merge branchName to master by following command

$ git merge branchName

If 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 diff

Following 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

websourceblog

ReactJs, NodeJs, Amazon Web Services, Symfony, Laravel, CodeIgniter, Zend Framework, WordPress, Drupal, Magento, Angular

Recent Posts

How to reset WSL 2 user’s password?

You can easily reset WSL 2 users' password, by just following the following steps. Open…

2 months ago

DreamHost Web Hosting

DreamHost a web hosting company, founded in 1997. It is offering sort of hosting services,…

10 months ago

How to add submenu or menu in any specific menu option in WordPress programmatically?

Menus in WordPress are highly versatile and can be easily modified to change in your…

11 months ago

Laravel 8 error target class controller does not exist.

Laravel is famous and robust PHP framework, widely used in different type of projects. While…

1 year ago

Define Private Methods/Functions in Python Class.

Python is very powerful and famous language, which allow us to write code as per…

2 years ago

Working with dates in PHP.

In this article, I am going to show you how we can get specific dates…

2 years ago