Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
computer_science:git:resources:git_cheatsheet [2020/11/19 15:30] – carlossousa | computer_science:git:resources:git_cheatsheet [2023/12/01 12:07] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== Git Cheatsheet ====== | ====== Git Cheatsheet ====== | ||
+ | |||
+ | ===== Initialize & Add Remote Git ===== | ||
+ | |||
+ | <code bash> | ||
+ | git init | ||
+ | git remote add origin <url> | ||
+ | git fetch | ||
+ | git branch --set-upstream-to=origin/< | ||
+ | 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 ===== | ===== Delete All Commit History ===== | ||
Line 23: | Line 47: | ||
# Finally, force update your repository | # Finally, force update your repository | ||
git push -f origin master | git push -f origin master | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Pushing new branch requires username / password ===== | ||
+ | |||
+ | <code bash> | ||
+ | # Fix with | ||
+ | git remote set-url origin git@github.com:< | ||
+ | |||
+ | # Push the branch | ||
+ | git push origin < | ||
</ | </ | ||