How to manage frappe,erpnext and custom app on github

Hello Community,
I am new to both frappe & github.
I made some changes in frappe(files and related doctypes) and ERPnext(doctypes) and i also made a custom app(with some doctypes and some client scripts). I know one thing certainly that these changes are getting saved in database and not in actual code.
So, i wanted to know how can I assure that all these things get exported in the app code aswell. So that when i install app in new project, these remain the same. I want to know how will i have to manage github.
Will i have to firstly fork original frappe,ERPNext code to my own github and download it and then make changes and how will changes in frappe,ERPNext changes will be saved in actual code.
And i also wanted to know how i will be able to import my custom app code when i get it on production server.

I am a newbie so please guide me through this.