Skip to content

Instantly share code, notes, and snippets.

@saifsmailbox98
Last active June 30, 2017 22:47
Show Gist options
  • Save saifsmailbox98/a898f97859dbfec1d0d4c3a1fcbaf519 to your computer and use it in GitHub Desktop.
Save saifsmailbox98/a898f97859dbfec1d0d4c3a1fcbaf519 to your computer and use it in GitHub Desktop.

Make a new folder (aka directory)

$ mkdir <FOLDERNAME>

Navigate into an existing folder (aka change directory)

$ cd <FOLDERNAME>

List the items in a folder

$ ls

Turn Git on for a folder

$ git init

Check status of changes to a repository

$ git status

View changes to files

$ git diff

Add a file's changes to be committed

$ git add <FILENAME>

To add all files changes

$ git add .

To commit (aka save) the changes you've added with a short message describing the changes

$ git commit -m "<your commit message>"

Add Github username to Git

$ git config --global user.username <USerNamE>

Add remote connections

$ git remote add <REMOTENAME> <URL>

Set a URL to a remote

$ git remote set-url <REMOTENAME> <URL>

Pull in changes

$ git pull <REMOTENAME> <BRANCHNAME>

View remote connections

$ git remote -v

Push changes

$ git push <REMOTENAME> <BRANCH>

Add remote connections

$ git remote add <REMOTENAME> <URL>

View remote connections

$ git remote -v

You can create and switch to a branch in one line:

$ git checkout -b <BRANCHNAME>

Create a new branch:

$ git branch <BRANCHNAME>

Move onto a branch:

$ git checkout <BRANCHNAME>

List the branches:

$ git branch

Rename a branch you're currently on:

$ git branch -m <NEWBRANCHNAME>

Verify what branch you're working on

$ git status

Check Git status

$ git status

Pull in changes from a remote branch

$ git pull <REMOTENAME> <REMOTEBRANCH>

See changes to the remote before you pull in

$ git fetch --dry-run

Merge a branch into current branch

$ git merge <BRANCHNAME>

Change the branch you're working on

$ git checkout <BRANCHNAME>

Delete a local branch

$ git branch -d <BRANCHNAME>

Delete a remote branch

$ git push <REMOTENAME> --delete <BRANCHNAME>

Pull from a remote branch

$ git pull <REMOTENAME> <BRANCHNAME>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment