[Cheat Sheet] How to use Git!?

Basic commands:

git clone https://cloneurl               # create a local copy of a git repo
git add my/file.lua                      # add a file you want to commit and/or push
git commit -m "added my awesome changes" # create a commit so you can always switch back
git push                                 # push your local commits to the configured server

check your commit before the push
git show

typo but not yet pushed?
git commit --amend
This opens your default text editor so you can edit your commit message.

some change missing for your commit and still not pushed yet?

git add file.lua
git commit --amend 
git push                                 # or just in case a git show again? ;)

bring your own mod up to date in general
git pull

also good to know:

temporally revert changes
git stash

show stashed changes
git show stash

apply stashed changes
git stash apply

get a commit from the original mod you forked or from another fork
git fetch https://origin/url

git cherry-pick 21a3123s1212d313f # (the hash of the commit)

bring forked mod with less changes simply up to date (this method also works with other forks, thats why i note it this way)
git pull https://wanted/repo

reset your mod completly, even commits
git reset --hard HEAD

reset your mod to a specific upstream commit
git reset (hard?) 21a3123s1212d313f # (the hash of the commit)

reset a messed up or (bring back a) deleted file
git checkout file.lua


Below is a link where you can know about git commands and practice too. Only 15 mins. spare time. :innocent:

Try Git tutorial

1 Like

Documents that helped me:

https://www.frank-rahn.de/git-mit-github/ [german]
http://rogerdudler.github.io/git-guide/index.de.html [german and …]
https://git-scm.com/book/de/v1 [german and …]

1 Like

This post is now a wiki.
Users with trust_level_1 and above can edit it.

1 Like