Git - Verbs

Git Verbs – Alphabetized

yuck!

Add

To add files that you have placed in the folder into the repository which are then tracked in the source control system.

Git add *

The Asterisk (*) is a filename. So you could also say somthing like

git add readme.md

This adds a single file named readme.md to the repository.

  • I have noticed the filename is case sensitive. If you add the file with the correct casing it will give you a success message. But if you provide the wrong casing it does not return an error message.

Branch

To create a branch

Git branch Mark 

Creates a branch named Mark

Many people will include a Ticket Number or Ticket Number and description to the branch name.

With spaces use surrounding “Quotes”

Git branch

Gives you a list of branches that have been created

Checkout

To change to a branch

Git checkout Mark

Navigates to the Mark branch

Think of this like a chdir command however you are not changing directory, you are telling the repository to go to the copy of source code filed under the Mark branch.

When you start changing the files in the directory (either with file explorer, or notepad or VS tools) you are making changes to the ‘mark’ branch.

Clone – Copy’s an entire GIT structure from one server to another.

This is an alternative to git init. It downloads a project to your computer and initializes that folder to hold this new project.

You’ll use this when you go to a GIT repository (like GitHub and BitBucket) and want to get a project. These commands usually have a function called Clone, when when clicked gives you a link which you paste into your client side GIT program.

Cd \repo
git clone https://github/dotnet/docfx.git

This will download the docfx project onto your computer. Including a history of changes.

Commit

To lock those files into the repository

git commit –m “Initial Comment”

-m – This is a comment associated with the commit.

“Initial Comment” a comment stored in the repository

Fetch

To synchronize the branch with a another branch, likely stored in a central repository

Init

Used to initialize a folder to hold a new project. Use once per root project.

Merge

Merge the contents of the leave you are working on into a master’er branch.

Push

Pushes the contents of one branch to another branch. Usually this is used to push the contents of a branch on a local computer to the central repository.

Reset

This is the command to throw away your work and go back to an earlier version.

Status

This will show which files within the current branch have been modified