A basic introduction to Git and how to use it effectively as a team of developers. Topics covered include:
- Cloning
- Branching
- Merging
- Pull requests
- Rebasing
- Reviewing
- Keeping history clean
- Making messages meaningful
Cloning $ git clone [email protected]:Gridstone/... repoDir $ cd repoDir $ git status On branch master Your branch is up-to date with ‘origin/master’. nothing to commit, working tree clean
Each commit represents an action $ git log --oneline 57d969e Remove password from login screen. 6ccf065 Configure email validation in login screen. 27e5021 Add email to login screen. 8c6bf5c Merge pull request #37 from sm/settings-screen You should be able to replay a set of commits on a codebase and watch the changes take effect.
Committing $ git status Changes not staged for commit modified: LoginScreen.kt $ git add LoginScreen.kt $ git status Changes to be committed: modified: LoginScreen.kt $ git commit -m “Change login params to have phone number.”
Think about the commits in the PR • Both PR submitter and merger need to consider what commits are about to be merged into master • The submitter needs to proactively push amend commits
Rebasing $ git rebase master --interactive WHAT THE HELL. WHY IS VIM NOW POPPING UP!? WHY DO MY FILES HAVE <<<<<<< EVERYWHERE IN THEM!? $ git rebase --abort My first rebase.