Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Big Picture

Similar presentations


Presentation on theme: "The Big Picture"— Presentation transcript:

1 Github Tutorial Kan Qi kqi@usc.edu

2 The Big Picture

3 Local environment workspace Index
The directory in your file system where you hold your project source code. git init git clone <repo-url> Index containing a sorted list of file paths. git ls-files --stage git add git rm

4 Local environment - cont’d
Local repository .git directory in your workspace directory Hold branches and commits for each branch. HEAD refers to the currently checked out commit. git commit [-m] git pull <remote> <branch> git checkout <branch> git push <remote> <branch> git fetch git revert <commit-ish>

5 Remote repository Remote repository is a repository hosted somewhere on Internet or local network. Commands available to manage remote repositories git remote [-v | --verbose] git remote add <name> <url> git remote remove <name> git remote set-url <name> <newurl> Four transfer protocols http local git SSH To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. You can have several of them, each of which generally is either read-only or read/write for you. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work. Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. In this section, we’ll cover some of these remote-management skills.

6 Collaboration - Typical workflow
Person A Setup project & repo push code onto github edit/commit pull/push Person B clone code from github edit/commit/push edit… edit… commit pull/push

7 Collaborating - clone git clone name>/<repository name>.git git clone

8 Collaborating - fetch, pull
Options for synchronizing: Fetch Fetch all the branches to local repository to be able to access the remote branches. git fetch <remote> Pull Pull the changes in remote branch and apply those changes directly to the workspace. Usually we need to solve conflicts after we pull. git pull <remote> <branch>

9 Collaborating - merge,push
Merge the current working branch with another branch. git merge <branch> Push Push the commit you make in local repository to remote repository git push <remote> <branch>

10 Demo - Collaboration User1 and user2 both clone the same project from github git clone User1 make some changes and commit to the remote master branch. git commit -m “edit readme file for greeting” git push origin master User2 is also doing some changes in local and commit to local repository. When user2 pushes the local commit, it conflicts with the remote master branch. User2 pulls the commit from remote and solve the conflicts. git pull User2 commits and pushes again. git commit -m “solve the conflict about the readme file”

11 Demo - Collaboration - cont’d
User2 creates a branch named “maintain_branch” in local. git checkout -b “maintain_branch” User2 makes changes and commit into “maintain_branch” git add --all & git commit -m “added maintain branch” User2 pushes the branch into remote repository git push –-set-upstream origin maintain_branch User1 fetches the branch from the remote repository and merge the two branches by solving the conflicts. git fetch git merge maintain_branch User1 pushes the master branch with the changes from maintain branch back to remote repository git push origin master

12 577a course project requirements
Every team should host their project on github in private repository Register a student account, and you get up to 5 private repository quota Add TAs as collaborators. Commit message format Git commit -m “your comment” E.g git commit -m “added username format check function”


Download ppt "The Big Picture"

Similar presentations


Ads by Google