Clone, fetch, pull & stash
Git - Quick Reference
2 min read
Published Jun 19 2025
Guide Sections
Guide Comments
Cloning a repository
This is used to create a brand new project from an existing repository.
To create a copy of an existing repository:
This will clone the specified repository in to the current directory
To specify the directory:
This does the same but copies the files in to the specified named directory.
Fetching a repository
Get the latest commits from the remote repository, but don't merge them to the current branch:
Current branch remains unchanged.
You can inspect the changes with git diff
or git log
.
Useful to see whats changed before pulling.
Pulling a repository
Fetch and merge into the current branch:
Fetches changes from the origin/main
and merges them in to the current branch. May cause merge conflicts.
Pull and apply local commits:
Will add your local commits on top of the remote ones to give a cleaner history.
Stashing
Temporarily shelve or stash your changes that are not committed, so you can work on something else, and bring them back later:
Stashes changes in tracked files and clears them from the working directory.
You can then safely checkout another branch, do your work, then to go back to what you were doing:
Which applies the most recent stash and removes it from the stash list.
To keep bring back a stash but also keep it in the stash list:
To stash everything, including untracked changes:
To list all stashes:
To show the most recent stash:
To apply a specific stash from the list:
To delete a specific stash:
To delete all your stashes: