Session 1.1: Git and GitHub
1. Install Git.
2. Create a GitHub account.
3. Create an empty repository on GitHub.
- After you log into your GitHub account, go to the "repositories" tab;
- Press the "New" button;
- Give a name to your repo, add a short description, leave it as a public repo, and add a README file. Then, press create.
4. Clone your newly created repository to your system
- Use GitBash, cmd, etc.
- Choose a directory that you want to clone the repository to.
- In Git Bash, you can use
git clone
followed by the repository address (URL), for example:
$ git clone http//github.com/~/ESI.get
5. Change your current directory to the imported repository, for example:
$ cd ESI
6. Check the status of your repository by using git status
.
$ git status
You should see the following message
On branch main Your branch is up to date with ‘origin/main’. nothing to commit, working tree clean
7. Within your project/repository, make some modifications to the Readme.md file. Then, check the status of your repository again. You should see the following message:
... modified: README.md ...
8. You can add the new/modified files (currently in the Working directory) to the Staging area by using git add .
The "." will add all your new files in the Working directory to the Staging area.
$ git add .
9. Check the status of your repository again. You should see something like the following:
... modified: README.md ...
10. You can commit these changes using git commit
, which will move the files/changes from the Staging area to the Local repo.
$ git commit –m "a text message to describe the commit".
–m "text": is a text message that is used to describe the commit.
11. Check the status of your repository again. You should see the following, which informs you that you can use git push
to publish your local commits.
$ git status On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) Nothing to commit, working tree clean
12. Push the changes from the local repo to the remote repo using git push
, and you might be asked to authorize this activity by providing your credentials.
$ git push
13. The files/updates should have been pushed to the remote repo. Check your remote repo (GitHub) and you should see them.
14. Made some simple changes in your remote repo, i.e., change the readme. Then, update your local repo based on the remote one using git pull
.
$ git pull origin
15. Check your local repo and you should see the changes.
How can you add your team members to your repository
- In GitHub, go to the repository where you want to add collaborators.
- Press on "setting".
- Within the "access" block, press on "Collaborators" (you might be asked about your credentials).
- Now, you can invite your group members by pressing the "add people" button.
- Your group members will receive emails inviting them to be collaborators, which they need to accept.