- Before you do anything else, make a backup of your local project!
- Check through all the folders in your local project and if any of them don't have any files in them, add a file to them. This matters when it comes time to push the changes to GitHub, because the push command won't send empty directories. A common practice is to put the empty .gitkeep file into empty directories.
- Grab all available operating-system updates.
- Update the apt database:
sudo apt update
- Configure your git username in place of John Doe's:
git config --global user.name "John"
- Configure your git user email in place of John Doe's:
git config --global user.email "john.doe@example.com"
- (Optional) Configure your editor as nano instead of the default of vim:
git config --global core.editor "nano"
- Create a personal access token on GitHub:
- Since GitHub no longer uses passwords for remote access from the command-line, you'll need to create a GitHub personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token. Note that this will need to be repeated at the interval you specify, so keep the link handy.
- Configure GitHub's default branch name for new repositories:
- Go to your main GitHub profile.
- Click Settings in the context menu.
- Click Repositories in the left panel.
- Check if your Repository default branch name at the top of the right pane is master. If it's not, change it to master and click the Update button. Note that we're doing this because git uses master as the default branch and although you can change that, you have to jump through a lot of hoops to do so, so this is just easier.
- Click your GitHub profile picture in the top right corner.
- Click Your profile in the context menu.
- Go to your main GitHub profile.
- Click Repositories in the menu.
- Click the New button.
- Type a repository name into Repository name text box.
- Optionally type a description into the Description text box.
- Choose whether to make it a public or private repository.
- Do not put a check-mark in the Add a README file box.
- Leave the Add .gitignore setting as is unless you're familiar with it and have a preference.
- Choose a license.
- Click the Create repository button to create the repository and open its main page. Note that you'll see several instructions, including a blue box with some quick setup information in it. That's exactly where you should be. Leave the browser open while you go on to the next section.
- Open your local project's main directory in a terminal window on your computer.
- Initialize git in that folder:
git init
- Check the status with the
git status
command, which will give you a message letting you know you are on the master branch and giving you some additional information. - Add all of your project files with the
git add .
command. - Check the status with the
git status
command to see which files were added. - Commit the change with a meaningful comment noting that this is the initial import of your project:
git commit -m "Initial import of project."
- Go back to your GitHub repository's main page and copy the first line you see that starts with git remote add origin and ends with the URL to your GitHub repository.
- Go back to your terminal window and paste that line in to let git know where you'll want your changes to go.
- Push your changes to your GitHub repository with the
git push -u origin master
command. - Type in your username at the prompt.
- Type in your personal access token at the password prompt.
Refresh your GitHub repository's main page to see that your project files have been added.