To help myself, here is a cheat sheet for sending updates to Github using the terminal.
To add a repo to Github
- Create it manually on Github
- Go to your repositories on Github.
- Click New (green button)
- Follow instructions, and include a ReadMe file.
- Then connect your local project folder to it using terminal (instructions here) https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
- Change the current working directory to your project folder (cd and drag folder into terminal)
- Initialize the local folder as a Git repository
- Type in “git init”
- Stage the file for commit to your local folder.
- Type in “git add .”
- Commit the file that you’ve staged in your local folder
- Type in “git commit -m “first commit” “
- Connect the local folder to the online repo you created
- Copy paste the URL in your browser
- Paste into your terminal “git remote add origin yourURL”
- Confirm the URL is correct
- Type in “git remote -v”
- Push the actual files to your now connected project folder
- Type in “git push -u origin master”
- If needed type in git push -f origin master” (because creating repo made a readme which is not part of your local project, -f forces the push even with conflicting files)
Going forward, when you want to make updates:
- Stage the files you want to add.
- Type in “git add . “
- Commit the file that you’ve staged in your local repository.
- Type in “git commit -m “add existing file”
- Push the changes in your local repository to GitHub.
- Type in git push origin your-branch
If I’m given a message that I can’t escape out of because my master repo is one or more commits ahead of my local repo, then I use these commands in the Terminal.
- press “i”
- write your merge message
- press “esc”
- write “:wq”
- then press enter
If you want to get updates from someone else who added to your repo.
- Then enter a “git pull” command into Terminal to get the latest master repo onto my computer.