I have recently found myself learning Git as part of my Data Science upskilling journey. I consider it as a means to do configurations on your local machine with version control to track changes and managing projects.
I worked on a project that had me set up a folder, add new files and upload to Github. Some of the commands I used include:
- mkdir: This is used to create a new directory e.g. mkdir myproject.
- pwd: This is used to check the parent working directory e.g in my case the parent working directory will be my Desktop where I created myproject folder.
- cd: This is used to open or go into a directory in the example above it allows me to open the myproject directory.
- ls: This is used to list the files within a directory. Within myproject folder when the command is run it will give an empty list since I had not added files into the folder.
- touch: This is used to create a new file e.g. touch README.md
- echo: This is used to write into a file e.g you want to enter text into README.md. The following text will be added to the README.md file using echo:
- echo "#My first project for Data Analysis" > README.md which will title the file as My first project for Data Analysis.
- echo "##Things I learnt" >> README.md which will add a new sub title to the file.
NB: echo + > **= overwriting the file and **echo + >> = adding to the file.
- cat: This command is used to read file e.g cat README.md to view the text written on README.md.
Now that I was able to set up the folder with a README.md file, I was also able to upload it to Github. I used the below commands to add to a repository on Github:
git init: This initializes the directory i.e myproject transforming it to a repository that will be containing the project files on Github.
git add: This is for adding files to staging on Github.
git commit -m "message": This saves the staged files permanently into the repository created.The git commit describes the changes being made.
By the end of running the above commands I was able to successfully create myproject repository on Github with a README page describing the project.
Top comments (0)