DEV Community

Cover image for GitHub CheatSheet I
Niharika Pujari
Niharika Pujari

Posted on

GitHub CheatSheet I

What is GitHub?

GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside 40 million developers.

Alt Text

Let's get started...

  • If you already have a project in which you would like to add git, then you can turn an existing directory into a git repository using:

Alt Text


Branch

  • Create new branch:

Alt Text

  • Switch to the specified branch and update the working directory:

Alt Text

  • Delete specified branch:

Alt Text


Synchronize changes

  • Update your current local working branch with all new commits from the corresponding remote branch on GitHub.

Alt Text

  • Uploads all local branch commits to GitHub

Alt Text


Make changes:

In order to commit your local changes you need to stage them first:

  • Snapshots the file in preparation for versioning

Alt Text

  • You can use the following command to add all your local changes for staging:

Alt Text

  • Records file snapshots permanently in version history Alt Text

Pull Request

Once you have committed all your changes you need to create a Pull Request against the repository you want to merge your changes.

Steps to create a Pull Request:

  1. Push your local branch to remote repository using git push
  2. Go to github.com, you will be prompted with your branch name, click Create Pull Request.
  3. Once you have approvals on your pull request, it is time to merge your branch into master.
  4. Use Merge pull request or Squash and Merge button to merge your pull request into the repository.
  5. Once merged, your local changes are now available in master branch.

Top comments (0)