Imagine yourself as a software developer in company. You're working in a team of 5 people. Everyone needs to make changes to files
To collaborate, we need a way of:
- Tracking the version of the files
- Distribute the files to each member
- Using changes from other people
Git
Git is a version control system. There are many version control systems, but git
is a very popular one. Git provides a set of commands that allow you to interact with it.
Version Control System
It's a system that allows you to record edits to files over time. Hence the name. Version control systems allow groups of people to edit the same files and have a clean way of controlling the version and order of changes.
-
Download the project from your online codebase
Git terms: Clone the repository
-
You now have your own copy of the project
Git terms: You now have a working directory
-
After editing your file
Git terms: You have unstaged changes
-
Tell git which files you changed
Git terms: Stage your changes to your local repository
-
Upload your changes to your online codebase
Git terms: Push your changes to your remote repository
-
When someone else uploads changes you can grab them
Git terms: Pull the changes
-
macOS
# install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install git brew install git
-
Linux (Debian based)
apt-get install git
-
Windows
- Install the software
- Open the terminal (macOS, Linux) or git bash application (Windows)
# Check if git is installed
git
- Should see a list of possible commands
- Visit https://github.com/ and click on the "Sign up for Github" Button.
Adding your own contributions to our workshop webpage
- Visit https://github.com/CarletonSLAM/git-workshop
- Click on the "Clone or download" button and copy the HTTPS URL in the text box.
-
Open your terminal or (or Git Bash if you're on Windows) and navigate to a folder you want to clone to
cd path/to/directory
-
Clone the repository
-
Navigate to you the repoository
cd git-workshop
-
Create your own branch
git branch YOUR_BRANCH_NAME
-
Checkout to your branch
git checkout YOUR_BRANCH_NAME
-
Navigate to the docs folder and open index.html in a text editor.
-
Add your own name and program in a h3 tag in the middle of the body tag i.e.
<h3>Jacky - Software Engineering </h3>
- Save the file.
We now want to stage our changes and commit them.
git add index.html
git commit -m "Description of your changes"
# Check the status
git status
# Push to your branch if everything looks good
git push origin YOUR_BRANCH_NAME
Go to the repository website and you'll be prompted to make a pull request