Skip to content

Instantly share code, notes, and snippets.

@brygrill
Last active August 21, 2017 13:29
Show Gist options
  • Save brygrill/672bb84b0edd7fa17c347873c82b0fcd to your computer and use it in GitHub Desktop.
Save brygrill/672bb84b0edd7fa17c347873c82b0fcd to your computer and use it in GitHub Desktop.
Github Basics with Visual Studio Code
@brygrill
Copy link
Author

brygrill commented Aug 20, 2017

Clone Repo

screenshot 2017-08-20 05 13 20

$ git clone https://github.com/facebook/react.git
$ cd react
$ code .

@brygrill
Copy link
Author

Switch Branch

In VS Code, click on the master branch in the bottom left corner of the screen. Select the new branch to checkout:

screenshot 2017-08-20 05 21 35

@brygrill
Copy link
Author

brygrill commented Aug 20, 2017

Create new Branch

Select Create new Branch:

screenshot 2017-08-20 05 28 44

Give it a useful name:

screenshot 2017-08-20 05 30 12

@brygrill
Copy link
Author

brygrill commented Aug 20, 2017

Sync to Remote

This step is not necessary, but I find it useful. Your new branch name will be reflected in the bottom left corner of VS Code. Clicking the cloud will push your branch to Github.

screenshot 2017-08-20 05 33 47

Select origin (Github):
screenshot 2017-08-20 05 37 04

@brygrill
Copy link
Author

Stage and Commit changes

Change can be viewed from the Source Control panel in VS Code. Select the files to stage and add a useful message.

screenshot 2017-08-20 06 33 30

Cmd/Ctrl + Enter will commit staged changes. Your commit count will accumulate on bottom bar:

screenshot 2017-08-20 06 38 34

@brygrill
Copy link
Author

brygrill commented Aug 20, 2017

Push changes

Push changes from the bottom bar:

screenshot 2017-08-20 06 38 34

On Github you will see the pushed branch:

screenshot 2017-08-20 06 52 31

@brygrill
Copy link
Author

brygrill commented Aug 20, 2017

Pull Request

Click on Compare & pull request:

screenshot 2017-08-20 06 52 31

Or:

  • Pull Requests tab
  • New Pull Request
    • Base is parent branch (dev)
    • Compare is your feature branch

Then click on Create pull request:

screenshot 2017-08-20 07 00 00

@brygrill
Copy link
Author

Merge Branch

Click on the Merge pull request button:

screenshot 2017-08-20 07 03 02

And confirm:

screenshot 2017-08-20 07 04 36

Then you can delete the branch if that makes sense for the project/branch:

screenshot 2017-08-20 07 05 23

All changes will now be reflected in the parent branch, dev in our case.

@brygrill
Copy link
Author

Sync changes locally

Check out the parent branch:

screenshot 2017-08-20 07 09 32

Your local version of the parent branch will be behind. Sync the changes from Github:

screenshot 2017-08-20 07 10 44

Optionally, delete your local branch:

$ git branch -d feature/<branch-name>

screenshot 2017-08-20 07 14 03

Optionally, prune origin so your list of remote branches is in sync with Github:

$ git remote prune origin

screenshot 2017-08-20 07 16 56

Before:

screenshot 2017-08-20 07 16 13

After:
screenshot 2017-08-20 07 17 43

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