Application Programming Hend Alkittawi Version Control Introduction To Git And Github INTRODUCTION We watched a few videos from the following course on Udacity: Version Control With Git VERSION CONTROL - Collaborative software development necessitates a system for source control and versioning! - A version control system facilitates simultaneous updates to the same software and manages any conflicts created! - There are a few version control system options - CVS - Concurrent Versions System - SVN - Apache Subversion - GIT - a distributed VCS (not the only one) VERSION CONTROL GIT - Developed by Linus Torvalds around 2005 - Open source, under the GNU GPL (General Public License) - Distributed, in that every directory on every computer is a full-fledged repository - It has a complete history, version-tracking capabilities - Independent of network access, or a central server - Use as command-line or via GUI GIT - To create a local Git Repo 1. Create a new project directory mkdir WorkingDir 2. Move into that new directory cd WorkingDir 3. Initialize Git repository git init 4. Create/edit project files 5. Stage files in the project directory git add . 6. Commit tracked files in Git storage git commit -m "a msg" Git Repository Working Directory file1 file2 Staging Area GITHUB - Web-based Git repository hosting service - Provides cloud storage, public/private repos, free accounts - Home to lots of open source software! - To use Github 1. Access a remote repository on Github.com 2. Pull down the latest version of the code to local 3. Add edited files to the source code 4. Commit edits to the local version git commit -m "short msg" 5. Push the changes out to the server git push git pull git add File.java VERSION CONTROL - Summary of Git Terminology - Repo - repository - Init - initialize a repository - Commit - Push/Pull - Clone - copy a remote repo locally - Branch - a separate version of the main repo that allows working on different parts of a project without impacting the main branch. VERSION CONTROL - Git and Github - You can choose how you want to use Git and Github - Command line - Browser http://github.com - GitHub Desktop http://desktop.github.com - IDE VERSION CONTROL - Some useful resources - Hints for using eGit (Eclipse plugin) - Resolving merge conflicts - Effective Git: - Tutorial: https://git-scm.com/book/en/v2 https://try.github.io/ README FILES - A code readme file should include dependencies, description of functionality, etc. - A repo readme file should describe project(s) in the repo, contributors, functionality, license(s), contribution guidelines, known issues, …. - A README file is created using markdown language! - Example: README.md template · GitHub README FILES - More Readme - A Beginners Guide to writing a Kickass README ✍ | by Akash - Top ten reasons why I won't use your open source project |> Changelog - GitHub - hackergrrl/art-of-readme: :love_letter: Things I've learned about writing good READMEs. - How To Write A Great README - GitHub - jehna/readme-best-practices: Best practices for writing a README for your open source project - zalando-howto-open-source/READMEtemplate.md at master TUTORIAL Using Git/Github in Android Studio Generate a personal access token and save it somewhere! (Under your Github account > Settings > Developer Settings) Check the repository created under your team in CS3443 Github organization OR create your own repository under your account Create your project in Android Studio then create a local Git repo (Android Studio > VCS > Enable Version Control Integration, select Git) Create your project in Android Studio then create a local Git repo (Android Studio > VCS > Enable Version Control Integration, select Git) Stage files (Right click on app > Git > Add) Commit to local repo (Right click on app > Git > Commit Directory…) and add the unversioned files Rename local branch to main (to match the remote branch name) -- IMPORTANT -- Copy the https URL for the remote repo Add the remote repo Add the remote repo Add the remote repo Fetch Note: Since we added a README to the remote repo we need Rebase before we Pull. You do not need to Rebase before you Pull if you did not create a README in the remote repo - you can skip slides 27 and 28. Rebase (we are just using it here because our local and remote repos initially do not have a “common history”) Pull from remote repo Pull from remote repo Push to remote repo Push to remote repo Modify file(s) on Github (similar to if someone else modifies the files) Modify file(s) on Github (similar to if someone else modifies the files) Pull changes to local repo Modify file(s) locally Stage, commit and push to remote repo (like above) Check the remote repo CODE DEMO - Show how to use Git in Android Studio DO YOU HAVE ANY QUESTIONS? THANK YOU! @ hend.alkittawi@utsa.edu By Appointment Online