Upload
others
View
30
Download
0
Embed Size (px)
Citation preview
Lab 1: Git
Software Engineering Lab
CSE406: Software Engineering
Except where otherwise noted, the contents of this document are Copyright 2020 Gayeon Kim, Gwanggyu Choi, Youn-geun Ahn, Hakjin Lee and Scott Uk-Jin Lee All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without author’s expressed written permission.
Git
VCS(Version Control System)
Database for ‘Version’
Why use VCS?
• Collaboration
• Backup
• Tracking source code
• Tracking what happened
• Reduce side-effectwhen you develope a new module
Centralized Version Control
Remote Team Repository(SVN)
Work Space(PC
)
Distributed VC(Team-Scale)
Remote TeamRepository(Github)
Local Repository(PC)
Work Space(PC)
Distributed VC(Project-Scale)
Local Repository(PC)
Remote Project Repository(Github)
Remote Team Repository(Github)
Local Repository(PC)
Git Workflow
(Staging Area)
Git Install
• OS X• http://sourceforge.net/projects/git-osx-installer/
• Windows• https://git-scm.com/download/win
• Linux• $ apt-get install git
Github
• Sign up
Click
Github
• Sign up
Click
Github
• Sign up
Github
• Sign up
Click
Check your Email
Github
• Create new remote repository
Click (if you are already registered in GitHub)
Click (if you are new GitHub user)
Github
Repository Name
Click
Click
Github
Click
Remote Repository URL
Click
Git - Work Space
Use git bash (Mac user can use terminal)
(your local workspace)
Click
Git - Work Space
git init
Set current directory to
Git workspace
Git - Work Space
git config
git config sets your user information which is usedfor authentication to access private remote repository.
Git - Work Space
git remote add / git pullNaming Remote Repository(insert yours https://github.com/YourID/YourRepoName.git)
git pull origin master
Pull from remote repo
README.md pulled
* Pull = Fetch + Merge(i.e. Receive current remote repository
+ Merge them to my local repository)
Git - Staging Area
.git
‘.git’ has index of files and changes.
Git - Staging Area
git status
Display current HEAD commit
& Tracked/Untracked files
Git - Staging Area
Add file to Staging Area(index)
you can use * (if you want add all
files(fixed or new))
git add
Git - Local Repository
git commit
Commit all added changes & save to Local Repository
git commit –m “Your commit log or message”
Git - Remote Repository
git push
hello.txt added to Remote repository
Push Local to Remote
Basic Work Flow
1. git init
2. git remote add [repoName] [url]
3. git pull [repoName] [branch(e.g. master)]
4. Working…
5. git add *
6. git commit –m “commit message”
7. git push [repoName] [branch(e.g. master)]
8. Repeat 3~7
Exercise
1. Create an remote repository
2. Pull remote repository to your workspace.(if you can’t pull them, try --allow-unrelated-histories option)
3. Create a program It’s double dash - -
Ex) if you input “1” then print your name.
4. Add & Commit to local repository
5. Push them to remote repository(if you can’t push them, try -f option)
6. Add functionwhich print your introduce when you input “2”
7. Update your remote repository