Git & Github Setup - Sloathking/Foolish-Wizardz GitHub Wiki

Git & GitHub setup

NOTE: The GE document says to create a new private github repo to store the django project. However, I believe we all already have a private github repo from the first GE called cs3300-version-control so I just created the portfolio and subsequent django project in that existing repo. If this is not ok, I will update the documentation, but for now I did not have to re-create a new private repo for the django project.

If you still want to create a new repo, here’s how: Open the folder where your portfolio folder is, right click and select ‘Open Git Bash here’ or open your preferred terminal/command line interface.

These commands will link the local repository to a remote GitHub repo:

git init # initializes a repository in the current folder
echo "#CS3300 Private Repo" >> README.md # created a README file
git add . # adds all files to the staging area
git commit -m "Initial commit" 
git branch -M main # creates a main branch
git remote add main <URL of GitHub repo>
git push

You will need to go to GitHub.com and create a repository there to get the repository URL. Creating a GitHub repo on the website Resources: https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github
https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository
To get the URL of the GitHub repo, you need to create a repo on the website: Go to GitHub.com and sign in. Click on Repositories and click on the New button.
Name the repo and make it private
Do not select add a README file and do not add a .gitignore or license. Just leave those options as they are.
Click “Create repository”
Find the SSH link under Quick Setup and use this command from earlier
git remote add main
Then you can push your local repo
NOTE: You may have to set the upstream branch before you can push to the new repo

Add a .gitignore file to the new repo

Use this article to add and format a .gitignore file

touch .gitignore
vi .gitignore

Once in the vi editor
press the “i” key to enter the Insert mode
and paste (right click and select paste) the contents of this file in.
Then find the Environments section and add “/djvenv” or /”whatever you called your virtual environment”

Then press the “Esc” key, you should see the “Insert” at the bottom go away
and then the colon “:” key
followed by “wq” and hit enter.

That combination of keys will escape you from Insert mode, open the command window, and wq will “write” and then “quit” or save the file. After that, you should be back to the normal terminal screen. Check this article if a file is not being ignored.