Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
engineering:computer_science:git:resources:git_cheatsheet [2024/08/16 13:56] – removed - external edit (Unknown date) 127.0.0.1 | engineering:computer_science:git:resources:git_cheatsheet [2024/08/16 13:56] (current) – ↷ Page moved from refractor_computer_science:git:resources:git_cheatsheet to engineering:computer_science:git:resources:git_cheatsheet carlossousa | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== | ||
+ | |||
+ | ====== 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 ===== | ||
+ | |||
+ | <code bash> | ||
+ | # Checkout | ||
+ | git checkout --orphan latest_branch | ||
+ | |||
+ | # Add all the files | ||
+ | git add -A | ||
+ | |||
+ | # Commit the changes | ||
+ | git commit -am " | ||
+ | |||
+ | # Delete the branch | ||
+ | git branch -D master | ||
+ | |||
+ | # Rename the current branch to master | ||
+ | git branch -m master | ||
+ | |||
+ | # Finally, force update your repository | ||
+ | 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 < | ||
+ | |||
+ | </ | ||
+ | |||