mirror of
https://gitlab.com/ric_harvey/git-guide.git
synced 2024-11-23 20:24:02 +00:00
1.4 KiB
1.4 KiB
Git Cheat Sheet
Here are a collection of useful git commands covered in this guide so far:
Clone a Repository
# Use SSH if you want to commit back HTTPS is fine for cloning
git clone <REPOSITORY_URL>
Stage Changes for Commit
# Add a single file
git add <FILE>
# or add all files
git add .
Commit Changes
# See a log and edit message in editor
git commit -a
# Add message on command line
git commit -m "Commit message"
Push Changes to the Remote Repository
git push
Create a New Branch
git branch <BRANCH>
Switch to a Different Branch
git checkout <BRANCH>
Merge Changes from Another Branch
# First check out to the target branch
git merge <BRANCH>
Other useful commands
Look at the git log
git log
Stash changes
Removes your changes and takes you back to the original state of the repo
git stash
Follow me for more guides
[Git Guide](https://gitlab.com/ric_harvey/git-guide) by [Ric Harvey](https://awscommunity.social/@Ric) is licensed under [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/?ref=chooser-v1")