-
Notifications
You must be signed in to change notification settings - Fork 0
Cheatsheet: Git for Simutrans
This cheatsheet assumes that your Github repository is set up as origin
$ git checkout <MY-BRANCH>
$ git diff <A-BRANCH>..<ANOTHER-BRANCH>
$ git checkout -b <MY-BRANCH>
$ git fetch --all
$ git checkout --track <THEIR-REPO>/<THEIR-BRANCH>
$ git push -u origin <MY-BRANCH>
$ git merge <OTHER-BRANCH>
If you want to retain changes in the present working directory, as though you had edited but not committed them:
$ git reset --soft HEAD~1
If you want to delete the changes forever:
$ git reset --hard HEAD~1
$ git name-rev <SHA>
$ git revert <SHA1 SHA2 etc.>
Git will then prompt you to edit any files that have conflicts. When you have done this:
$ git revert --continue
If you want to abandon editing while there are still conflicts:
$ git revert --abort
$ git remote add <NEW-REPO> <http://THEIR.REPO.URL>
$ git branch -u <THEIR-REPO>/<THEIR-BRANCH>
Change main
to master
if the repositories predate that change
If necessary, add the upstream repository as upstream
$ git remote add upstream https://github.com/<THEIR-USERNAME>/<THEIR-REPO>.git
First, critical, step is to make sure that you are on your main branch and have committed any changes!
$ git status
$ git fetch upstream
$ git rebase upstream/main
You now need to push these changes to your own repo on GitHub. Use --force
because otherwise git prefers the GitHub version
$ git push origin main --force
If necessary, rebase the branch you are working on
$ git checkout <BRANCH-NAME>
$ git rebase main
To get the commit history of line 15 of simworld.h
in the present working directory:
$ git log -L15,+1:'./simworld.h'
To get the history of the 5 following lines
$ git log -L15,+5:'./simworld.h'