Share
Embed
Transcript
22 slides
-
NISHAN CHATHURANGA Software Engineer 99X Technology (Pvt) Ltd. University of
Moratuwa Faculty of Information Technology -
Version control systems are a category of software tools that
help a software team manage changes to source code over time. Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members. What is version control -
By far, the most widely used modern version control system
in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. What is Git -
For us to share and work collaboratively with other developers,
we require access to a Git-based hosted service. • GitHub • Bitbucket • GitLab • Microsoft Visual Studio Team Services Git can be accessed and managed using command line tools. There are graphical User Interface (GUI) clients such as • Git extensions • Source tree • Tortoise Git -
GitHub, Inc. is a United States-based global company that provides
hosting for software development version control using Git. It is a subsidiary of Microsoft What is Github -
changes server changes checkout changes changes changes changes origin It’s
not necessary to have a central location to store all the versions of a project, instead developers and programmers copy (called clone) the main project to their local hard drive, so everyone has a physical mirrored copy of it to work on. -
Create a repo Go to Github.com -> Click on +
-> Click on `New Repository` -> Give repository name -> Click `Create repository` -
> git init > git remote add origin <origin_url> --
do your changes -- > git add . > git commit -m "first commit" > git push -u origin master -
changes YourRepo origin > git clone <origin_url> -- do your
changes -- > git add . > git commit -m "initial commit" > git push –u origin master Clone a repo 1 2 3 -
changes you / repo origin forking upstream fork someone /
repo 1 2 3 4 pull request (PR) 5 -
changes you / repo origin forking upstream fork someone /
repo 1 2 3 5 pull request (PR) 6 4 -
> git clone <origin_url> -- do your changes -- >
git add . > git commit -m "initial commit" -- add upstream url, get changes from upstream -- > git remote add upstream <upstream_url> > git fetch upstream --all > //git pull > git push –u origin master -
Branches > git branch //lists all branches > git branch
<new-branch> //create new > git checkout <new-branch> //switch to > git checkout -b <new-branch> //create + switch -
merge > git checkout master //switch to > git merge
new-feature //merge new-feature to master > git branch -d new-feature //delete new-feature -
Merge conflict <<<<<<< HEAD this is some content to mess
with content to append ======= totally different content to merge later >>>>>>> new_branch_to_merge_later $ git merge new_branch_to_merge_later Auto-merging merge.txt CONFLICT (content): Merge conflict in mer ge.txt Automatic merge failed; fix conflicts and then commit the result. File > < terminal -
rebase > git checkout master > git merge feature >
git checkout feature > git rebase master Merge vs rebase -
GIT terminology Branch A version of the repository that diverges
from the main working project. Repository A repository is a folder whose contents are tracked by git. It is also known as a repo, in simple terms. Master The primary branch of all repositories. All committed and accepted changes should be on the master branch. You can work directly from the master branch, or create other branches. Clone A clone is a copy of a repository or the action of copying a repository. Commit Adding/saving the changes to the local repository -
HEAD HEAD is a reference variable used to denote the
most current commit of the repository in which you are working. When you add a new commit, HEAD will then become that new commit. Push Updates a remote branch with the commits made to the current branch. You are literally “pushing” your changes onto the remote. Rebase When rebasing a git commit, you can split the commit, move it, squash it if unwanted, or effectively combine two branches that have diverged from one another. Merge Taking the changes from one branch and adding them into another (traditionally master) branch.