Version Controlling using Git - The Basics

Version Controlling using Git - The Basics

E08272816864f87e6b904fb63758f5bf?s=128

Nishan Chathuranga

May 17, 2020
Tweet

Transcript

  1. Version controlling WITH

  2. NISHAN CHATHURANGA Software Engineer 99X Technology (Pvt) Ltd. University of

    Moratuwa Faculty of Information Technology
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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.
  8. On your mark ! Git set !! Go !!! DEMO

  9. Create a repo Go to Github.com -> Click on +

    -> Click on `New Repository` -> Give repository name -> Click `Create repository`
  10. > git init > git remote add origin <origin_url> --

    do your changes -- > git add . > git commit -m "first commit" > git push -u origin master
  11. 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
  12. changes you / repo origin forking upstream fork someone /

    repo 1 2 3 4 pull request (PR) 5
  13. changes you / repo origin forking upstream fork someone /

    repo 1 2 3 5 pull request (PR) 6 4
  14. > 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
  15. 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
  16. merge > git checkout master //switch to > git merge

    new-feature //merge new-feature to master > git branch -d new-feature //delete new-feature
  17. 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
  18. rebase > git checkout master > git merge feature >

    git checkout feature > git rebase master Merge vs rebase
  19. None
  20. 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
  21. 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.
  22. Thank you https://forms.gle/BXwy52z1cDXqyGpn6 Please provide your feedback at https://github.com/fossmora/gitdemo Some

    useful links