Week 13 Version Control
Week 13: Version Control
1. Version Control¶
- A system that records changes to a set of files over time
- Easier to collaborate with other people
- Git
2. Types of Version Control Systems¶
- Centralized version control systems
- A single central server stores all files, and users check out files from this server.
- Distributed version control systems
- Every user has a complete copy of the repository, including the history of changes.
- Git
3. Git¶
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It allows multiple people to collaborate on a project, keeps track of changes made to files, and provides a way to revert to previous versions when necessary.
4. Github¶
GitHub is a platform for hosting and collaborating on Git repositories. It builds on Git by providing a web-based interface, collaboration tools, and features for version control. GitHub is widely used by developers, researchers, and organizations to manage projects, share code, and collaborate efficiently.
5. Sign up the GitHub Account¶
- Create a GitHub Account
- Include a personal email as back-up email
6. Repository in Github¶
A repository (or 'repo' for short) on GitHub is essentially a storage space where your project's files, including code, documentation, and other resources, are stored.
More detail about Repository find in GitHub Docs
7. Customize profile¶
7.1 Create new repo¶
Click + on the top right corner
Make sure your repo name is the same as your user name
Set is as Public and Select 'Add a README file'
GitHub will display your profile README on your profile page if all of the following are true.
- You've created a repository with a name that matches your GitHub username.
- The repository is public.
- The repository contains a file named README.md in its root.
- The README.md file contains any content.
7.2 Small Tricks to polish profile¶
7.2.1 Emoji¶
Copy emojis and paste them in file
7.2.2 Static Bage¶
'any_text', 'you_like' and 'blue' are user-defined Modify Static Bage per you needed
For example is defined as https://img.shields.io/badge/My-LinkedIn-blue
Format that create a LinkedIn badge that connect to your associated account
- [](link to content)
Copy below code to file then you will see a badge tha connect to you relevent account
7.2.3 Dynamic badges¶
Dynamic badges can show metrics for your repo or project.
10. Repo in Github¶
10.1 Initialize Repo from Existing code¶
git init
git add .
git commit -m "initial commit"
10.2 Create a new Repo in Github¶
- Create a repo "SSJ302_lab10"
- Create a README.md file
10.3 Clone an existing Repo from remote to local¶
- Clone this remote repository to local computer
git clone <repository_url>
Now navigate into your new git repository.
- .git: Git stores information about the project in this special hidden .git sub-directory. If you delete it, you will lose the project's history.
10.4 Add content to your repo¶
Using the html file from Lab 10 as an example to host a web page on Github
10.5 Push change from local to Remote¶
- Make some change to local repository, then update the remote pository based on Step 1 - 3.
- To add files to the staging area, run the following command:
git add .
- To commit the changes, run the following command. Repalce message with your comment to this commit. -m flag (for "message")
git commit -m 'message'
- Push the change from local repository to remote repository
git push
11 Syncing¶
Sometimes, we need to sync our local repository with the main branch (the default branch) on GitHub. For example, imagine you have two computers: one at home and one at work. You made changes on your work computer and pushed them to the main branch on GitHub. However, when you return home, you realize your local copy is outdated.
11.1 Pull change from Remote to local¶
It’s an easy way to synchronize your local repository with upstream changes.
git pull
12. Collaboration¶
There two main ways to collaborate on github:
- Adding individual collaborators to a project
- The fork & pull model
The first method give your collaborator full permission to make changes.
The second method allow you accept individual contributions without full access.
13. Fork & Pull¶
13.1 Fork a repo¶
- On Github, navigate to https://github.com/gisynw/SSJ302_final_project
- In the top-right corner of the page, click Fork
13.2 Commit a change¶
- Clone the repo to your local computer
- Create a word document (Firstname_Lastname.docx) in the repo
- Add 1-2 sentence description of the project
- Add, commit, push the change
13.3 Submit a pull request¶
Navigate to your GitHub repo to check out your change.
When you make change to your SSJ302_final_project repo. Your repo is different from mine, and from everybody else. Next is to share your changes wiht others
- Click pull request
- New pull request