CS1102 Session 01 Lab Practice Git and GitHub
CS1102 Session 01 Lab Practice Git and GitHub
• If you do not install Git please follow the instructions uploaded on Blackboard.
• If you do not have an account on GitHub please sign up here: https://github.com/
4. If this is your first-time using Git, you need to set your user.name and user.email in
configuration using the following commands.
git config --global user.name “YourName”
git config --global user.email “YourEmail”
|Page1
(CSCE 1102)
Fundamentals of Computing II Lab
Note: you can notice that the word ‘(main)’ will be written after using the git init command
indicating that you are inside a Git rep ository now.
Note: you will find a hidden folder called “.git” created automatically inside your working
directory after using the git init command.
8. Commit the changes into the local Git repo using the git commit command.
Note: you should choose a descriptive message to write after the ‘-m’ option describing the
changes made in this commit.
9. View the status of the repo using the git status command.
Note: the message ‘nothing to commit, working tree clean’ indicates that all the changes
made in your working directory are already committed to the local repo.
|Page2
(CSCE 1102)
Fundamentals of Computing II Lab
10. Edit the “Sample.txt” file and add your ID then save and close it.
14. Git commit with a descriptive message and view the status.
15. Use the git log command to view the list of all commits.
Note: You can use the ‘--oneline’ option to display each commit in one line.
|Page3
(CSCE 1102)
Fundamentals of Computing II Lab
3. Choose the repository name, select add readme file, and press “Create Repository”.
|Page4
(CSCE 1102)
Fundamentals of Computing II Lab
4. In GitHub, on the “Code” tab press on Code to get the URL of the remote repo.
8. Use the git clone command to take a copy of the remote repo to the “git-cloned-repo”
folder. Note that the URL entered after the git clone is the URL of the remote repo.
After the git clone, you will find the “git-cloned-repo” folder now contains the folder of the
remote repo.
9. Go inside the cloned folder using the cd command. For example, here the repo name is
“git-learning”.
|Page5
(CSCE 1102)
Fundamentals of Computing II Lab
10. In the cloned folder, create a “codeSample.cpp” file and edit it by adding an empty main
function.
Note: if you have a problem in creating a “.cpp” file you can download it from blackboard and
move it to your cloned folder.
12. Git push your changes to the remote repo using the git push command.
13. Refresh the repository on GitHub and you will find the “codeSample.cpp” file on GitHub
14. Click on the file and edit it by clicking on the edit icon.
15. Add the following line in the file and then click on commit changes with a descriptive
message.
|Page6
(CSCE 1102)
Fundamentals of Computing II Lab
16. In Git Bash, use the git pull command to download the changes from the remote repo.
Note: if you open your cloned folder you will find the “codeSomple.cpp” edited.
Good Luck,
Your TA. Walaa Alkady
|Page7