Workflow with Git - marist-sga/documentation GitHub Wiki
Getting Started
Watch this video.
TODO: Table of contents
Terminology
| Term | Meaning |
|---|---|
| Repository (Repo) | All the files of a git project (code tab on Github) |
| Git | Command line tool that manages versions of a project's code |
| Github | A website that allows users to put their git projects in the cloud (and access them easily) |
Clone This Repository
TODO: pictures/gifs
- Download Git for your machine.
- NOTE: Please install the command line application, NOT the GUI (graphical user interface) version.
- Open the command line (Windows) or terminal (Mac)
- Type
cdand then enter the path of the directory where you want to download the repository.cdstands for "change directories." The terminal/command line acts as a text-based version of your file-system.- In order to download a repository to the correct place, you have to
cdto the place where you want to download it.
- Enter
git status.- If your command line says
Command "git" not recognizedor something along those lines, please try installing git again. - If your command line says
fatal: Not a git repository (or any of the parent directories): .gitplease proceed!
- If your command line says
- Enter
git clone https://github.com/marist-sga/sga-website.git- Your command line should produce a lot of download messages.
- Behind the scenes git is going to the url after
clone(this repo), and downloading all those files into your current directory.
- After git is done downloading all the files, enter
- Mac
ls - Windows
dirs
- Mac
- You should see the top level folders for the website. Go to Windows Explorer on Windows or the Finder on Mac and check to see if those files are there (they should be).
- Open the project with your favorite text editor (Atom or Sumblime)
Making Changes
- Make changes to the files you want and save them.
- Go to the command line or terminal and
cdto thesga-websitegit repository folder on your machine. - Enter
git statusto view which branch you're on and which files need staging.- If it stays
On branch developmentplease switch to a different branch. - There should be a section of "Unstaged Files" (the files you changed).
- If it stays
- Type
git addthen file name of an unstaged files.git addtells git "yes, please track these files for me"- Tip: instead of typing
git addfilename, entergit add .to add all unstaged files.
- Enter
git commit -m "Short descriptions of the updates I made"- The
commitcommand tells git "Yes, please save my progress at this point using the files I've staged" - The
-mis called a flag. It's an optional addition to thecommitcommand. It stands for message. It allows you to create a message to go along with your commit. - Please provide a message with every commit you make. It doesn't have to be long, just a quick update.
- The
- Enter
git push origin branchNamepushtakes all your current commits and lets git know that you want to keep those changes.originis the default name of the repository that's on the cloud (Github in this case). git has two repositories: local and remote. The local repo is on your machine. The remote repo is the one you see on Github.branchNamePlease put your branchName here. Please do not push tomaster.
Branches
- Branches are used so developers can work separately on the same project and so the changes they make can be reviewed later in the pull request before they are merged into the base branch (development).
- Naming convention:
- The branch name should correlate to what you're working on. So if you had to create a page called James Bond your branch name would be
jamesBondorjamesBondPage. As long as the branch correlates to what you're working on that is fine.
- How to use branches:
- Enter
git branch your-branch-namethis creates a new branch. NOTE: It is case sensitive. - Enter
git checkout your-branch-namethis switches to the new branch. - To make sure you did it correctly enter
git branchand if your branch is highlighted in green then you did it! Yay! - To just switch to a branch that is already created use
git checkout branch-you-want-to-switch-to
NOTE: You should not be making changes on the development branch (like ever) or else you will be mocked (and you don't want that).