Tuesday, February 20, 2018

Git: pulling and creating a new branch from the command-line

I am working with a team that relies on Windows applications for managing source code with a Git repository. To inspire them to use the command-line (which supports Windows, OS/X, and Linux in a standard fashion), I am creating standard recipes for them to follow.

  1. Pick the branch name. A branch should be associated with a single bug or task so branch name such as Task-123 or Bug-456 are acceptable because they map to the specific work item being addressed.
  2. From a console window, navigate to the directory into which a git repository will be cloned:

  3. Running the following from the console windows (assuming the branch to be created is Task-335 (which maps to Task-335: Fix PiplelineStageStatus names (changed Free to New):
  4. git clone https://YOUR_VANITYNAME_HERE.visualstudio.com/_git/Server

    CD Server

    git checkout -b Task-335

    The URL used in cloning will depend on the Git provider used (GitHub, BitBucket, VisualStudio.com). The link above is formatted for VisualStudio.com which is provided by Microsoft (for free) but is git all the same.
  5. To see the current branch simply type the following:
    git status

    Invoking "git status on a branch with no code modification simply displays the current branch name:

  • Remember "git clone" is cloning a repository not simply getting a branch as you would in TFS or SVN. The name clone is precisely what is happening.
  • The "git checkout -b" is the action that creates the new branch.

No comments :

Post a Comment