GitHub Cheat Sheet - meyermicrobiolab/Meyer_Lab_Resources GitHub Wiki

Highly recommended resource:

Happy Git and GitHub for the useR

Basic Git Commands

For the most part, using git is an easy and quick way to optimize the development process. Usually making a repository and hosting it on GitHub follows only four steps:

  • Initialize the Repo
  • Add files to the Repo
  • Commit the files to the git stream
  • Push the files up to GitHub

Make an existing Folder a Repo

git init

Clone/Download an entire Repo

git clone [URL]

Add a file to be tracked

git add [filename]

adding every file in the folder can sometimes be quicker than adding every file by name. This can be accomplished by using

git add .

Using "add" only adds these files to a queue to be tracked and committed later.

Committing the files to Git

git commit -m "[message]"

Think of "commit" like commenting your code. Not only does "commit" submit the changes to git but it also adds a log of the changes made. The message is important for you to be able to tell what was changed during each commit. This does mean that the changes have been pushed onto the remote repo being hosted on GitHub. To do that we need to push the changes to GitHub.

Push changes made onto the remote Repo

git push

This is the command that will actually change update the code on the remote Repo.

Common Git errors

Merge Conflicts

If the master files have been edited and you have not updated your local repo you can get a merge conflict. To fix first pull the changed files from the remote repo before _push_ing to the remote repo again.

git pull

Commit Errors

Make an error on the commit message?

 git commit --amend

Add Errors

Accidentally added a file that you didn't need?

git reset [file]

Additional Resources

⚠️ **GitHub.com Fallback** ⚠️