-
Notifications
You must be signed in to change notification settings - Fork 2
Intro to Git
Git is a version control system.
It lets you save “checkpoints”, which are save points of your code.
It also enables collaboration with “branches”. Each person can work on their own branch without affecting other people's code or the master copy of the code.
Have you ever made copies of the same file to save your changes? (I.e. project1, project_FINAL, project_FINAL_ACTUALLY) With Git, you don’t have to!
Github is a service that lets you manage Git repositories (projects).
It stores Git repositories (projects) on the cloud.
- repository (repo)
- tracked file
- commit
- branch
- master branch
- merge
- merge conflict
- push/pull
- pull request
This is the project git will keep track of. The files on your own computer are your local repo and the files on Github are the remote repo.
A file that is “tracked” is one that we want Git to keep track of changes for. This is most of our code. Files we don’t want to be tracked would be library files, binary files, secrets (passwords, logins) etc.
A commit is a snapshot of the repo at the current point. Think of it like a save checkpoint for the code. You can always revert back to a previous commit.
This is your independent line of development that contains commits. Everything you change here will not affect others’ code. It also groups together commits. For example, if you wanted to create a new page, you would probably create a new branch for that.
This is the final version of code. The website is deployed from master, aka the code for the website at wece.ece.illinois.edu comes from the master branch.
Merging is when you combine the changes from two branches. When you are done making changes to your branch, we will merge it to master.
This happens when two branches make different changes to the same piece of code. Git won’t know which change to keep.
Push is when you upload your code to Github. Pull is when you download code from Github. Always make sure you have the most recent version of code by pulling before you start development.
A PR (pull request) is a request to merge your changes from your branch into another branch (usually master). It allows people to see and review your changes.
-
git clone <url>
: make a local copy of a git repository -
git add <filename>
: add new files or stage changes to be committed -
git commit
: commit the staged changes, adds a new “checkpoint”-
-a
: Add all changes of tracked files -
-m
: Add a message to the commit
-
-
git push
: publish changes to a repo hosted on a remote server (GitHub) -
git pull
: update local repo with new changes from remote repo
- If you don’t have the repo:
git clone
- If you do:
git pull
- Make a new branch for your feature:
git checkout -b <branch-name>
- Make your changes, and commit often:
git commit -m “add a commit message”
- Publish your changes:
git push
- Make a PR (on the Github website) – see How to make a pull request.