Git & Github cheat sheet:

Git & Github cheat sheet:

·

2 min read

Git and Github - Andersen Lab Dry Guide

Git Commands:

  1. git init: Initialize a new Git repository in the current directory.

  2. git clone [repository_url]: Clone a remote repository to your local machine.

  3. git add [file]: Add a file to the staging area.

  4. git commit -m "Commit message": Commit the changes in the staging area with a descriptive message.

  5. git status: Check the status of your repository and see which files have changed.

  6. git diff: Show the differences between your working directory and the staging area.

  7. git branch: List all branches in your repository.

  8. git branch [branch_name]: Create a new branch.

  9. git checkout [branch_name]: Switch to a different branch.

  10. git merge [branch_name]: Merge changes from a different branch into the current branch.

  11. git pull: Fetch and merge changes from a remote repository to your local repository.

  12. git push: Push your local changes to a remote repository.

  13. git log: View the commit history.

GitHub Commands:

  1. git remote add origin [repository_url]: Connect your local repository to a remote repository on GitHub.

  2. git push -u origin [branch_name]: Push a branch to the remote repository for the first time.

  3. git pull origin [branch_name]: Fetch and merge changes from the remote repository to your local repository.

  4. git clone [repository_url]: Clone a remote repository to your local machine.

  5. git fork: Create a copy of a repository on your GitHub account.

  6. git pull-request: Create a pull request to suggest changes to a repository.

  7. git merge [branch_name]: Merge changes from a different branch into the current branch.

  8. git branch -d [branch_name]: Delete a branch.

These commands should help you get started with Git and GitHub. Remember to refer to the official documentation for more detailed information on each command and its options.

Did you find this article valuable?

Support Anurag's Blog by becoming a sponsor. Any amount is appreciated!