This guide covers the day-to-day git workflow you'll use in
CSE 333: keeping your local and GitLab repositories in sync,
recovering from common mistakes, and tagging commits for submission.
All commands below are run from your CSE Linux environment (attu or a CSE Linux VM). Your GitLab repository and your local copy do NOT sync automatically, so it's your responsibility to keep both up to date and avoid stale copies. The workflow here should suffice for CSE 333; for more depth, see the Git Community Book.
Navigate to anywhere within your local repository and run:
$ git pull
.gitignore that omits object
files (.o) and editor backup files automatically; add more
entries there as desired.
Make sure you are in your local repository and that all changes are saved before running the following commands:
$ git pull # make sure your local copy is up to date with GitLab
$ git add <files> # stages files to commit to GitLab
. (period) as
<files>, which stages all
added/deleted/modified files in the local repo because
. represents the current directory.
git add command that you don't want committed to the
GitLab repository.
$ git commit -m "<message>" # add a descriptive message about your update
$ git push # push your changes to GitLab
Keeping your workspace organized is crucial to a smooth, efficient workflow. Frequently updating your local and GitLab repositories reduces the chance of getting into weird situations. Nevertheless, it's common to end up in a "Git spaghetti ball" every so often, so here are some useful survival tips and commands.
The following git commands are ways to manage local changes
to your repository before pushing to GitLab:
HEAD of the
branch if you don't want your changes anymore:
$ git reset --hard HEAD
$ git checkout HEAD -- <path to file>
$ git reset --soft HEAD~1
$ git stash
$ git stash pop
$ git stash drop
git stash.
This is a way to remove a commit that you pushed to GitLab but no longer like. These instructions take inspiration from the GitLab documentation.
git pull.