Spring 2023
Smith College
Learn how to use git to effectively collaborate
git add
: Stage the filegit commit -m "<YOUR MESSAGE>"
: Commit staged filesgit pull
: Pull from GitHubgit push
: Push files to GitHubgit status
git log
(pro-tip: git log --oneline --graph --decorate --all
)git diff
git revert <FILES>
The hidden .gitignore
file lets you tell git “I do not want you to pay attention to these files or folders.”
This can be very handy if you want to:
.csv
filesbranch ->
<- merge
git checkout <NAME OF BRANCH>
git checkout -B <NAME OF BRANCH>
git merge <NAME OF BRANCH>
When you push a branch to GitHub, it will ask if you want to make a pull request to merge that branch into main.
Creating a request is the best way to merge your branches, as it allows you to use several powerful collaboration tools.
Sometimes git/GitHub will tell you there is a conflict.
That’s not uncommon. It means two people worked on the same file and edited the same part of the code.
You need to tell git how to resolve the conflict by opening the file in question and committing the “real” version.
Getting a feel for how large the work done in a branch should be takes some practice. While I can’t give you a single answer, here are some guides to help.
Package Documentation
SDS 270: Advanced Programming for Data Science