-
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 are Git, Subversion and Mercurial
-
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
add
andcommit
. Record your changes in 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 Activity" project in Android Studio and use the built-in git support (VCS menu). It doesn't have all the commands of Git Bash or the command line but is convenient when working in Android Studio.
-
Add a TEXT file with a distinctive name (File/New/File)
-
Use "VCS > Enable Version Control Integration" to initialize a repository - choose "Git" as your VCS
-
Follow the git workflow
- View the repository status: using "Git>Commit" from the menu
- Stage the files to commit: select the file you created from the list (find it in the Unversioned Files list)
- Commit the changes with a comment: Type a commit message in the box, like "tests commit process in Android Studio" and click "Commit"
-
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 log
andgit log --oneline
- The person in your team with a GitHub account should "drive" first
- Fork (button in upper-left corner of) THIS GitHub repository to create a new copy in YOUR GitHub account
- Open Android Studio; use the menu option "File > New > Project from Version Control" with your GitHub URL
- Each person in your group should make at least two commits as shown above; use both the Android Studio terminal and Android Studio VCS to work with Git
- Push your changes to GitHub using the Android Studio "Git > PUSH" menu or the terminal command
git push
Submit the URL for the updated GitHub repository in Canvas