by Eric M. Baumel
Putting your project under source control with GitHub
This is the first of a series of mini-posts of various computer housekeeping tips, initially for my own use. Hopefully these may also be some some benefit for others.
Source control with git serves several functions: - It provides a method of keeping track of changes made to your code, so you can roll back to a previous save if needed. - If used with a remote hosting service such as GitHub, gives a convenient back up of your code in the cloud. - Allows easy collaboration with other developers. - Can be used by many providers for managing deployment.
Let’s Get Started
- Install git on your system, if not alread done: Git Install 
- Make directory to hold project 
For iOS development: Create Xcode Project - start with appropriate project type
- Navigate to your project folder using the command line. 
- In Terminal, put project under source control. - git init
- Create a - .gitignorefile.
A .gitignore file lists the files and directories you do not want under source control, such as hidden files (.DS_Store on MacOS) , environment files (.env), secure credentials, venv and test directories, etc.
- Once you have files ready to be placed under source control, view the files that have been created or changed. - git status
- Track these files so they can be commited. - git add .
- Commit the waiting files. - git commit -m “Project setup”
Only push commits that will build and run.
- Now that you have a local git repo on your system, get ready to save it on GitHub: 
- Create new repository on GitHub. GitHub: Create a repo 
- Push your local repo to the remote main branch. - git remote add origin <URL> git push origin main
- Continue your work in a - devbranch. This becomes your HEAD branch.- git checkout -b <new-branch>
Other Useful Git Commands
- git logShows all commits.
- git branch -avLists all local branches.
- git remote -vList all remote branches.
- git checkout <branch>Switches your HEAD branch.
- git branch -m <new-branch>Rename your HEAD branch.
- git branch -d <local-branch>Delete local branch.
- git push origin --delete <remote-branch-name>Delete remote branch.