This repository was homework for the ComIT course. The simulated situation is: I have to create a Python file and add it to a local Git repository. After that I have to create a remote repository on GitHub and then connect them both in order to send code to GitHub.
To solve this, I did the steps below:
- Open the git bash command line.
- Create the
helloworld.pyfile through the command line using nano. - Created the local repository and added the helloworld.py using the commands:
git initgit add .git commit -m “message”
There is no remote repository attached to the local one so, there is no need to: git push origin main
-
Create the remote repository Using GitHub on github.com
-
Returned to the local bash to connect the local repository to the remote one:
git remote add origin "https link"(from GitHub) -
Pulled the changes (files) from the remote repository:
git pull origin main --allow-unrelated-histories -
To do a final commit with all the files I edited the Python file again so I had something to commit. After the modification I could do:
-
git add . -
git commit -m "First change in the file" -
git push origin main
-
In the end, I pushed my file up to the remote repository.
