Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 2.2 KB

summary.md

File metadata and controls

55 lines (41 loc) · 2.2 KB

Summary

We've introduced the following basic git workflow using git on the command line:

Local operations

  • Staging files: git add <file>
  • Committing changes: git commit
  • Inspecting your workspace: git status
  • Reviewing history: git log

Syncing with a remote

  • Pushing local changes: git push

Typical use of git in a workflow

To clarify the above, when using git for a project we follow these steps:

  1. Initialise a local repository (git init), or clone an existing remote repository from GitHub (git clone).
  2. Write some code. Save the file to the working directory, e.g. mycode.R
  3. Use git status to see what is ready to add/commit and check file names.
  4. Stage the file using git add mycode.R
  5. Commit the file with a message using git commit -m "My first commit"
  6. Connect your repository to a remote GitHub repo (if you didn't start off by cloning a repository) or push the code to the remote GitHub repo using git push
  7. Write some more code. Save.
  8. Use git status to see what is ready to add/commit and check file names.
  9. Stage the file using git add mycode.R
  10. Commit the file with a message using git commit -m "Edits to first bit of code"
  11. Push the code to the remote GitHub repo using git push
  12. Write some more code...etc.

Most of the time you'll just be using four git commands: add, commit, push and status

Going further

Git and GitHub are extremely powerful and flexible systems and there is a lot more you can learn if you wish. Here are some starting points:

Documentation

  • git help <command>

Tutorials

Cheatsheets and quick reference