GitHub Cheat Sheet - meyermicrobiolab/Meyer_Lab_Resources GitHub Wiki
Happy Git and GitHub for the useR
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
git init
git clone [URL]
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.
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.
git push
This is the command that will actually change update the code on the remote Repo.
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
Make an error on the commit message?
git commit --amend
Accidentally added a file that you didn't need?
git reset [file]