DEV Community

Odipo Otieno (KwargDevs)
Odipo Otieno (KwargDevs)

Posted on

Git and GitHub

Git and GitHub cheat sheet:

Basic Commands Only

Git Commands:

  • git init: Initialize a new Git repository.
  • git clone <repository>: Clone a repository from a remote source to your local machine.
  • git add <file>: Add a file to the staging area.
  • git commit -m "<message>": Commit changes with a descriptive message.
  • git status: Check the status of your repository.
  • git push: Push local changes to a remote repository.
  • git pull: Fetch and merge changes from a remote repository.
  • git branch: List all branches in the repository.
  • git checkout <branch>: Switch to a different branch.
  • git merge <branch>: Merge changes from another branch into the current branch.
  • git log: View the commit history.
  • git diff: Show the differences between commits, branches, or files.

GitHub Commands:

  • git remote add origin <remote>: Add a remote repository URL as the origin.
  • git push -u origin <branch>: Push the branch to the remote repository and set it as the upstream branch.
  • git pull origin <branch>: Pull changes from a remote branch to your local branch.
  • git fork: Create a copy (fork) of a repository on your GitHub account.
  • git pull-request: Create a pull request to propose changes from a forked repository to the original repository.
  • git merge: Merge a pull request on GitHub.
  • git clone <repository>: Clone a repository from GitHub to your local machine.

Top comments (0)