To install git on windows go to https://git-scm.com/downloads and download the windows version of git
To install git on linux search for terminal in apps and open it then run the commands
sudo apt-get update
sudo apt-get install git.
One after the other
Go to https://www.github.com and create an account.
Run the following commands on Git Bash (or terminal in linux) replacing the name with yours and the email with your github email
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
Search for Git Bash (terminal in linux) and open it
Run the following commands on Git Bash (or terminal in linux)
ssh-keygen -t ed25519 -C "your_email@example.com"
- where the email is you github email
When asked for a password choose something you will remember
In github go to settings
Then Run the following command in commands on Git Bash (or terminal in linux)
Windows
clip < ~/.ssh/id_ed25519.pub
Linux
xclip -sel clip < ~/.ssh/id_ed25519.pub
Then Ctrl+V in the Key field select type Authentication Key and give it whatever title you want
And press Add SSH key
In your github profile in the Repositories section press New
Choose a fitting name and privacy policy for your repository
Choose the proper gitignore for the language you are using, this will stop the repository from being filled with unnecessary files.
Right click in the folder and select "open terminal" or equivalent
In path of the folder type cmd
and press enter
In your repository copy the ssh link
Open your terminal in the folder you want your repo to be in and type
git clone ssh_link
- where the ssh_link is the link you copied
write your ssh key password when asked
Now you are free to add whatever documents you want in your repo
After you are ready to send the documents you made to the repo open the terminal inside the folder and type the commands
git status
- to see what changes and comments haven't been added to the repo
git add file_name
- to start tracking a certain file with git
git add .
- to start tracking all files in the folder with git
git commit -m "message"
- to commit changes to repository (where message is a small summary of the changes you made, usually no longer than 20 words)
git log --oneline
- to see what commits have been made
git push
- to send all commits to the repository
Now the changes should be in the github repository
Go to the repository settings and add whoever you need
The people you invite will receive an email with the invitation to join the repository
When another collaborator makes a change to the repository it does not automatically make the change in your computer
To update the repo in you pc you need to use the command
git pull
Note: if the repository has been changed by someone you always need to pull all changes before you can push your commits to the repository
If you and a collaborator change the same file in the same place then git might not know which version to keep which results in a merge conflict.
You have to resolve these conflicts before pushing to the repository.
If you are using vscode you can use the source control feature to choose what to do.
From there select the files in conflict and decide what to keep and what to get rid of
In my case I will accept both changes
Now just add, commit and push to the repository like normal
Note: to avoid situations like this try to have collaborators working on different files or you can read on branches here: https://www.atlassian.com/git/tutorials/using-branches (They are a bit more complex and I will not cover them for now but if it turns out to be necessary I can do so later)
A README is a file usually in markdown format (https://www.markdownguide.org) that will be displayed at the bottom of your repository and has information about the project.
It's not a mandatory file but it can help explain to new comers the organization of the repo.
Joana Teixeira Mesquita, MEIC 1º ano, up201907878