## 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 ``` #### Stage Changes for Commit ``` # Add a single file git add # 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 ``` #### Switch to a Different Branch ``` git checkout ``` #### Merge Changes from Another Branch ``` # First check out to the target branch git merge ``` ### 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 [](https://awscommunity.social/@Ric) [](https://gitlab.com/ric_harvey) [](https://www.linkedin.com/in/richarvey/)
[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")