Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
computer_science:git:resources:git_cheatsheet [2020/11/19 15:28] – created carlossousa | computer_science:git:resources:git_cheatsheet [2023/12/01 12:07] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== | ||
+ | |||
====== Git Cheatsheet ====== | ====== Git Cheatsheet ====== | ||
- | ===== Delete All Commit History | + | ===== Initialize & Add Remote Git ===== |
- | | + | <code bash> |
+ | git init | ||
+ | git remote add origin < | ||
+ | git fetch | ||
+ | git branch | ||
+ | git pull | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Push Changes to Remote Git ===== | ||
+ | |||
+ | <code bash> | ||
+ | # Add all changes to the commit | ||
+ | git add . | ||
+ | # Commit with Comment | ||
+ | git commit -m "< | ||
+ | git push | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Delete All Commit History ===== | ||
- | Checkout | + | <code bash> |
+ | # Checkout | ||
+ | git checkout --orphan latest_branch | ||
- | '' | + | # Add all the files |
- | | + | git add -A |
- | Add all the files | + | # Commit |
+ | git commit -am " | ||
- | '' | + | # Delete the branch |
- | | + | git branch |
- | Commit | + | # Rename |
+ | git branch -m master | ||
- | '' | + | # Finally, force update your repository |
- | | + | git push -f origin master |
- | Delete the branch | ||
- | '' | + | </ |
- | - | + | |
- | Rename the current | + | ===== Pushing new branch |
- | '' | + | <code bash> |
- | | + | # Fix with |
+ | git remote set-url origin git@github.com:< | ||
- | Finally, force update your repository | + | # Push the branch |
+ | git push origin < | ||
- | '' | + | </ |