Team version control practice repository
Accompanying slides can be found here
Open your terminal, navigate to a place where you work on coding projects, and run the following command:
git clone https://github.com/abcdbug/team-up-with-git.git
If you have ssh setup on github you can do the following instead:
git clone git@github.com:abcdbug/team-up-with-git.git
First cd into the repo
cd team-up-with-git
And then checkout a new branch
git checkout -b unique-branch-name
Remember, DON'T WORK IN MASTER.
Add a new file or modify an existing file, save your changes, then run the following command:
git status
Run the following command to stage your files:
git add name(s)_of_file(s)_you_changed
Then commit your changes.
git commit -m "Added new file that does this and that"
Before pushing your code to the origin, first check to see if master has changed since you branched.
git checkout master
git fetch
git status
In an ideal world where everyone remembers not to work in master, you should always be able to pull
master.
Since life doesn't always go as planned, fetch first.
If git status
says you can fast-forward, then git pull
.
Assuming there are no changes on master since you branched, push your branch to origin.
git checkout unique-branch-name
git push -u unique-branch-name
If master changed since you branched, you will need to rebase on master and then git push
.
git checkout unique-branch-name
git rebase master
git push -u unique-branch-name
If the rebase gives you an error, it means you and somebody else where touching the same part of the same files. That's when we start to think about using the project management tools provided by github/gitlab.
Navigate to the team-up-with-git project page on github and submit a pull request for your work.