- Integrating Git into the project
- Setting up remote connections
- Staging and committing changes
- Pushing the changes to remote
- Fetching the changes from remote
- Working with branches
- Showing log history
In Android Studio, go to Android Studio > File > Settings > Version Control > Git. Click Test to ensure that Git is configured properly in Android Studio.
.gitignore
files are automatically added (one in the project root folder, and the app folder). Files like generated code, binary files (executables, APKs), local configuration files should not be added to Git. Those files should be excluded from version control. Here’s my initial .gitignore
file content:To add the project to the remote repository, go to Git > Manage Remotes :
To push your local changes to the remote repository, go to Git > Push.
To download the latest changes from remote, go to Git > Pull.
Go to Git > Branches
- Checkout: checkout master branch.
- Checkout As: checkout new branch from master
- Checkout and Rebase onto Current: checkout master and rebase feature branch onto it.
- Compare with Current: commits that exist in master but don’t exist in feature and vice versa.
- Show Diff with Working Tree: show the difference between the master and the current working tree.
- Rebase Current onto Selected: rebase master on feature.
- Merge into Current: merge master into feature.
- Rename: rename the master branch.
- Delete: delete the master branch.
Go to Git > Show History.