csci 2133 rapid programming techniques for innovation
play

CSCI 2133 RAPID PROGRAMMING TECHNIQUES FOR INNOVATION Lab 02: Prep - PowerPoint PPT Presentation

CSCI 2133 RAPID PROGRAMMING TECHNIQUES FOR INNOVATION Lab 02: Prep Lab: Basics of Git Instructor: Gang Liu Faculty of Computer Science Dalhousie University Lab Overview Creating repositories and sharing with TAs in future Git


  1. CSCI 2133 RAPID PROGRAMMING TECHNIQUES FOR INNOVATION Lab 02: Prep Lab: Basics of Git Instructor: Gang Liu Faculty of Computer Science Dalhousie University

  2. Lab Overview ■ Creating repositories and sharing with TAs in future ■ Git cloning ■ Git history ■ Git branches ■ Git diff ■ Git merge and merge conflicts

  3. Create repository on gitlab

  4. Invite members to your gitlab repo Please add instructor, TA, marker to your repo and give maintainer role permissions.

  5. Cloning the repository onto your local machine ■ Move to desired location on your system and CLONE your git repo with https for a local copy on your terminal >git clone <link> ( Please copy the link provided under “Clone with HTTPS” option ) <-Here

  6. Add to git ■ Create a dummy txt file called as “csci2133.txt” in your local cloned git repository and add it to git using: >git add -A

  7. Commit to git ■ Only changes that are committed to git will be recorded in the repository. So, to commit: >git commit –m “Initial commit”

  8. Push changes to git ■ If you want the changes to reflect online on the gitlab master branch, you have to push it using the command: >git push origin master

  9. Clone a github repository to understand some sample commands ■ An evil plan is on GitHub, you need to get a copy first ■ Here’s the https link: (DalCSS, 2016) https://github.com/DalCSS/GeekLabsGit.git ■ Can you clone the repository on your own? After cloning, please change directory to the local git repository

  10. Git log ■ This shows the history of the repository and the commits made earlier to this branch. Open “map.txt” to understand where you are. >git log

  11. Git checkout ■ If you want to move to a previous commit in the master branch, copy any one of the commit ids provided after “commit …” on git log. Check map.txt now. >git checkout 1bf609cdb9bc2b4872da38f0e88a9c1289fa17e4

  12. Git checkout for moving to a different branch ■ Firstly check all branches available using: >git branch –a Then move to the branch using “git checkout branchname” >git checkout minion Where, minion is the branch name. Now check “map.txt” again to understand where you are.

  13. Git diff ■ You can check differences between two commits across one file or multiple files using git diff >git diff commit_id1 commit_id2

  14. Git branch concepts  git checkout –b branchname This new branch will automatically contain all the content until the last commit made in the master branch before the creation of this branch. Branches run in parallel with the master and can contain code which is different from the master and then can be merged with the master using the command: >git checkout master Change to master branch >git merge branch_name Merge the new branch and its changes with the master branch >git push Push the changes to the repository

  15. Git merge and merge conflicts ■ Scenario: There is a master branch which has a file “file.txt” with the numbers “1,2,3”. Programmer A and B create two branches “branchA” and “branchB” respectively. ProgrammerA checks out to his branch “branchA” and changes “1,2,3” in “file.txt” to “1,3,3” and pushes the changes to his branch and merges it with the master branch. ProgrammerB (still unaware of the changes made by ProgrammerA) changes “1,2,3” on his unchanged copy “file.txt” to “1,4,3”. He pushes it to his branch “branch” and when he switches to master and tries to merge it with the master branch, he hits on a roadblock called as “merge conflict”.

  16. How to solve merge conflicts? ■ Pull the latest code before working on our branch everytime using: >git pull ■ Or when there is a merge conflict, the specific file can be opened on your local machine and git shows where the conflict is and it can be edited manually.

  17. References ■ Some material in the lab tutorials are and will be borrowed from Dr. Vlado Keselj, the previous instructor of this course. ■ DalCSS. (2016). DalCSS/GeekLabsGit . [online] Available at: https://github.com/DalCSS/GeekLabsGit.git [Accessed 9 Jan. 2019].

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend