How to start working with Git?
Table of contents
- Definitions
- Installation
- Authentication
- How to create a new repository on GitHub Desktop?
- How to publish your repository to GitHub?
- Managing access to your repository
- Important commands in Git
Definitions
What is Git?
Git is an open source version control system which tracks all the changes you made in your projects. Git has a remote repository which is stored on a server and a local repository which is stored on a private computer.
What is GitHub?
GitHub is a website and Internet service which allows to store your projects on a server - in your own repository, make changes, and collaborate with others.
What is GitHub Desktop Client?
It is a software which you can use it to manage your Git repositories locally on your computer without using the command line on Internet browser.
Installation
To start working with GitHub, perform the following actions:
- Create your account on GitHub: Create Account and verify your e-mail address.
- Install GitHub Desktop Client on your computer: GitHub Desktop Client.
Authentication
After you install GitHub Desktop, you can synchronize it with your own account on GitHub and configure it. If you selected two-factor authentication for GitHub you can generate your authentication code either from mobile message or an e-mail and verify your account. Further information you can find here: docs.
How to create a new repository on GitHub Desktop?
- Open GitHub Desktop on your computer.
- On a โLetโs get started!โ panel select Create a New Repository on your hard drive.
-
Name your repository and set its location on your computer.
๐ Note: It is recommended to use the shortest path, for example C: Git, as the repository is to be created inside the folder you selected for your local path.
- Select: Initialize this repository with a README and None in the Git Ignore and License menu.
- As you fill in the blanks, select Create Repository.
How to publish your repository to GitHub?
As you create your first repository on GitHub Desktop, keep in mind that it only exists on your computer. In order to publish it to the server (GitHub), perform the following actions:
- In the menu bar of GitHub Desktop select Publish repository. Name and Description are the same as you chose while creating the new repository.
- For the needs of our studies, mark keep this code private.
- Select Publish Repository.
- You can open your files in the repository on GitHub directly from GitHub Desktop.
Managing access to your repository
In order to invite a collaborator to your repository:
- On the server select Settings and Manage access.
- Invite your Vistula educators typing the userโs name account: martab0, db4rr.
- Wait for acceptance.
๐ Note: You can receive the notifications via e-mail so check your box regularly.
Important commands in Git
In the table below you can find useful commands being used on GitHub and GitHub Desktop. Familiarize with them to properly manage your workflow, add content, or make changes.
Action | Command | GitHub Desktop Client |
---|---|---|
Create a project | git init [project] | File > New repository |
Add a project to the remote server | git remote add origin [url] | Publish your repository to GitHub |
Retrieve the project from the server | git clone [url] | File > Clone a repository |
Add a file | git add [file] | Create or copy file |
Delete the file | git rm [file] | Delete file |
Save changes | get stash | Automatic |
Approve changes | git commit -mโ[description]โ | Commit to [branch name] |
Upload changes to the server | git push | Push origin |
Retrieve changes from the server | git pull | Fetch origin+ Pull origin |
Current status | git status | Changes/History/Current branch |
No tracking via git | Add to .gitignore | Add to .gitignore |