Useful Git Commands

  • strict warning: Non-static method view::load() should not be called statically in /home/john567/drupalganger.com/sites/all/modules/views/views.module on line 843.
  • strict warning: Declaration of views_plugin_display::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/plugins/views_plugin_display.inc on line 1877.
  • strict warning: Declaration of views_plugin_display_page::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/plugins/views_plugin_display_page.inc on line 481.
  • strict warning: Declaration of views_plugin_display_block::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/plugins/views_plugin_display_block.inc on line 193.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • strict warning: Declaration of views_handler_argument_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_argument.inc on line 770.
  • strict warning: Declaration of views_handler_sort_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_sort.inc on line 82.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • strict warning: Declaration of views_handler_filter_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 609.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 128.

Use Case: I create a local branch that I want to push into GitHub

git push -u origin local_branch_name

this will push that branch up to GitHub


 

Use Case: I want to pull and track a remote branch that I currently don't have in local

git checkout --track origin/remote_branch

this pulls the remote_branch to local, configures tracking it on the remote. Locally you will now be on that branch


 

Use Case: I want to delete a remote branch and its local branch

git push origin :branch_name

git branch -d branch_name

This pushes an empty to the remote and thus deletes remote branch. The second command deletes the local branc


 

Use Case: running git branch -a on my local repo shows remote branches which have been already deleted in the remote.

git remote prune origin

 

This fixes the information that local has about the remote. Now git branch -a will return the correct information about remote branches.


 

Use Case: I want to clone a git repo to specific changeset/revision: http://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset

 

 


Use Case: I went to a version of one file from one branch into the branch I'm working in.

Run this from the branch that you want to receive the file

 

git checkout otherbanch theFile.txt