-
Why Git?
-
There are other version control systems. There are a number of Version Control Systems out there. This alone should prove that version control is incredibly important. Examples
-
Git is the most popular and an industry standard.
-
It has some advantages over a centralized system, which has a single copy of the code:
- It's quick to take action on your own copy
- It works locally, on your own computer, and offline
- It makes having multiple branches, parallel worlds of code, easier
-
-
Git Gotchas
- Git can mean several things - the name of the source control technology, the functionality built into VS Code, the file formats and protocols that underlie the system.
- It’s both powerful (because it’s open-ended), plentiful (because it’s open source), and sometimes hard to use (because it’s open-ended).
- It takes practice, it's a learned skill, it's not intuitive - ask other developers about their Git disasters - everyone has a story.
-
Creating new repo and initial commit. The flow for using git starts with creating a directory (folder). The cycle as changes are made is
addandcommit. Small chunks as you go.- Configure your git
git config --global user.email "youremail"git config --global user.name "yourname"
mkdir SampleApp- create new folder named SampleAppcd SampleApp- move to the project foldergit init- initialize the repositorytouch README.md- create a new filegit status- view the repository statusgit add .- stage the files to commit and tell get what files to track, "." selects all the new files or files with changesgit commit README.md -m "New readme file"- add the changes to the repo with the named file, "-m" indicates message included
- Configure your git
-
Create a new "Empty" project in Android Studio and use the built-in git support (VCS menu). It doesn't have all the commands of Git Bash but is convenient when working in Android Studio.
-
Use "VCS > Enable Version Control Integration" to initialize a repository using "Git"
-
Add a TEXT file called "myFile" (File/New/File)
-
Follow the git workflow using "VCS>Commit". We need to complete staging for the changes
- select the file from the list (this takes care of the staging process - the
git addstep) - Type a commit message in the box, like "Adds myFile
- click "Commit"
- select the file from the list (this takes care of the staging process - the
-
Review the effect using the Terminal
- Open the "Terminal" tab "View > Tool Windows > Terminal"
- Check out the changes with
git log - See the difference between
git logandgit log --oneline
- Fork and Clone this GitHub repository
- Use both the terminal and Android Studio to work with Git
- Push your changes to GitHub
- Submit the URL for your updated repo in Canvas
