Version Control Git
August 18, 2026 at 7:19 AMGit at DigiPen Singapore
| Service | Address |
|---|---|
| Repositories | https://git.sg.digipen.edu/projects/<groupname> |
| Tickets, wiki, timeline (Trac) | https://trac-git.sg.digipen.edu/projects/<groupname>/timeline |
| Requests and problems | helpdesk.sg@digipen.edu |
You sign in with your DigiPen account. If a clone or push asks repeatedly for your password, that is an authentication failure rather than a broken repository — email the helpdesk.
Reference: DigiPen wiki Git FAQ
Request a team repository
Student (Team Leader) will need to send email to helpdesk.sg@digipen.edu with the following important details.
- Name of Group
- List of team members (DigiPen email ID)
- CourseCode and Instructor.
Thereafter, your repository will be accessible for the members and instructors via
Members will also have access to project-related SCM tool
How do I clone a repo?
# Clones to ./<project_name>
git clone https://git.sg.digipen.edu/projects/<project_name>
# Clones to ./<dir_name>
git clone https://git.sg.digipen.edu/projects/<project_name> <dir_name>
What state is my working copy in?
git status
Lists the following:
- Current branch
- Is branch up to date
- Are there any unstaged changes
- Changes in the staging index that are ready to be committed
- Committed changes which have not been merged
- Useful tips!
List all unstaged changes
# Normal output
git diff
# Highlighted output
git diff --color-words
# To view changed on staged files
git diff --staged
Create a new branch and switch to it
git checkout -b <branch-name>
Rename branch
git branch -m <new-branch-name>
Add files to the staging index
git add <file_name>
Dont forget to commit!
Commit your changes
git commit -m "<descriptive but short message about my commit>"
Push changes to a remote repo
git push
Pull changes from a remote repo
git pull
Switch to the last branch I was on
git checkout -
How do I search all changes ever made in my repo?
git grep "<something you want to find>"
How do I pull a specific commit from another branch onto my branch
git cherry-pick <sha-value>
Discard local file modifications
# Reset specified path
git checkout -- <local_path>
# Also works with multiple arguments
git checkout -- <local_path1> <local_path2>
Undo local commit
# Undo the last 2 commits, keep changes in working tree
git reset HEAD~2
# Undo the last 2 commits, discard changes
git reset --hard HEAD~2
Remove a file from GIT without removing it locally
# Or git remove --cached <filename>
git reset <filename>
Edit a commit message
# Starts $EDITOR to edit
git commit --ammend
# Replace the message directly
git commit --ammend -m "New message"
Add file to previous commit
git add <forgotten_file>
git commit --ammend
Clean local commits before pushing
git rebase --interactive
# If you don't have any tracking information for this branch add an upstream
git rebase --interactive origin branch
Revert pushed commits
# Revert specific commit
git revert <sha-value>
# Revert the second to last commit
git revert HEAD^
# Revert range of commits
git revert develop~4..develop~2
# To revert the changes to the working tree only
git revert --no-commit HEAD
Advanced and repair
Recipes for repairing a repository or rewriting history. Everything in this section is riskier than the commands above — read the whole recipe before running any of it.
Avoid repeated merge conflicts
git config --global rerere.enabled true
Locate merge that broke something
# Start the bisecting session
git bisect start
# mark the current revision as bad
git bisect bad
# Mark the last known good revision
git bisect good revision
⚠ These rewrite history. Anyone who has already cloned or pulled will have to re-clone, and a mistake here is not always recoverable. Make a backup copy of the repository directory first, and tell your team before you run them.
Remove sensitive data
git filter-branch --force --index-filter \\
'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' \
--prune-empty --tag-name-filter cat -- --all
Push to multiple git repos at the same time
# This does not preserve history!
git remote set-url origin --push --add <link_repo1>
git remote set-url origin --push --add <link_repo2>
git remote update
Make sure to push the changes!
Fix a broken repo!
# Run this and see what is dangling etc
git fsck --full
# These should clean those things up
git reflog expire --expire=now --all
git gc --prune=now
# Run this again to see if we have fixed it
git fsck --full
Remove all broken refs from a repo
# make a backup before attempting this
git for-each-ref --format='%(refname)' | while read ref; do git rev-list --objects $ref >/dev/null || echo "in $ref"; done
(echo HEAD; git for-each-ref --format='%(refname)') | while read ref; do git rev-list -g --objects $ref >/dev/null || echo "in $ref"; done
Delete all files and history from a repo [UNRECOVERABLE]
# Create a new empty repo with an initial commit
mkdir new
cd new
echo "This is the README" > README.md
git init
git add .
git commit -m "Add README.md (initial commit)"
# Add remote repo [the repo you want to delete] as origin
git remote add origin <url-to-remote>
# Mirror push to remote
git push origin --mirror
# Note: There will be dangling ref's left over which you can then garbage collect later if you please
# see: https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-push.html
Clone history, tags, and branches to a new repo
# Clone repo1
git clone --mirror <link_repo1> repo1_dir
# We need to retrieve all the tags from repo1
git fetch --tags
# ensure your local branches and tags are correct
git tag
git branch -a
# Set the origin urls
git remote set-url origin --push --add <link_repo1>
git remote set-url origin --push --add <link_repo2>
# Update remote tracking
git remote update
# Update the repos
git push origin --all
git push --tags