In this document, you will find all the steps you should follow when working on git and github (in the prework and during the bootcamp).
Prerequisites
- Administrator privileges
- Access to a command-line
- Your favorite coding text editor
- Username and password for the Github
Download Git for Windows
-
Browse to the official Git website: https://git-scm.com/downloads
-
Click the download link for Windows and allow the download to complete.
Extract and Launch Git Installer
-
Browse to the download location (or use the download shortcut in your browser). Double-click the file to extract and launch the installer.
-
Allow the app to make changes to your device by clicking Yes on the User Account Control dialog that opens.
-
Review the GNU General Public License, and when you’re ready to install, click Next.
-
The installer will ask you for an installation location. Leave the default, unless you have reason to change it, and click Next.
-
A component selection screen will appear. Leave the defaults unless you have a specific need to change them and click Next.
-
The installer will offer to create a start menu folder. Simply click Next.
-
Select a text editor you’d like to use with Git. Use the drop-down menu to select Notepad++ (or whichever text editor you prefer) and click Next.
-
This installation step allows you to change the PATH environment. The PATH is the default set of directories included when you run a command from the command line. Leave this on the middle (recommended) selection and click Next.
-
The next option relates to server certificates. Most users should use the default. If you’re working in an Active Directory environment, you may need to switch to Windows Store certificates. Click Next.
-
The next selection converts line endings. It is recommended that you leave the default selection. This relates to the way data is formatted and changing this option may cause problems. Click Next.
-
Choose the terminal emulator you want to use. The default MinTTY is recommended, for its features. Click Next.
-
The default options are recommended, however this step allows you to decide which extra option you would like to enable. If you use symbolic links, which are like shortcuts for the command line, tick the box. Click Next.
-
Depending on the version of Git you’re installing, it may offer to install experimental features. At the time this article was written, the option to include interactive options was offered. Unless you are feeling adventurous, leave them unchecked and click Install.
-
Once the installation is complete, tick the boxes to view the Release Notes or Launch Git Bash, then click Finish.
Debian/Ubuntu For the latest stable version for your release of Debian/Ubuntu
sudo apt-get install git
For Ubuntu, this PPA provides the latest stable upstream Git version
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
Homebrew Install homebrew if you don't already have it, then:
brew install git
Now, go to your GitHub account, if you don't have an github account create a new one.
Sign in to your existing github account with your login credentails.
-
Click on the green 'New or +' button to create a new repository.
-
A new repository page opens. Fill the repository name and click the green 'create repository' button to create a new empty repository.
- Open the gitbash or windows command terminal or linux or iterm2 in mac.
- Open your terminal and navigate to the location where you want to store the local version of your repository.
- To navigate use
cd
command. When you navigated to the correct folder in your terminal, run the following command:
$ mkdir prograd-sample-repo
Check the image below if you have any doubts:
- Once the directory is created, to create files In windows shell
echo >> filename
In linux and mac terminal
touch filename
To check if the file is created
In windows shell
dir
In linux shell or mac terminal
ls
Configure your local Git installation to use your GitHub credentials by entering the following:
git config ––global user.name “github_username”
git config ––global user.email “email_address”
Run the above commands one by one.
Note: Inside the double quotes give your github username and email.
The local repository process is finished with this step. Now we need to initialize the local repository before we proceed to the next step.
$ git init
To open the project in VS Code, you have to run the following command when you already navigated to the folder:
$ code .
If in doubt, check the following image:
Now we are ready to start working/making changes. Quickly go to the terminal and, while in the local repository, run the following command:
$ git status
This shows us that there were no changes made locally, yet.
After you made changes to your project, you can check which files you changed by running again:
$ git status
Currently, we demoed making changes to a single file. You might be making changes to one or multiple files; thus, you might see many files marked as modified.
In case you want to add just one file and you are not ready to add the others, you can do so with the following command:
$ git add <name of the file>
However, most likely, you would like to add all the changes so that you will use the following command more often:
$ git add .
👍 The dot represents all files in the current repository.
After all changed files are added, you should commit your files and add a commit message describing the things you have changed, with the following command:
$ git commit -m “<your message>”
After committing your changes, you need to add the remote url of your remote repository on GitHub with the following command to push the changes to remote repository.
git remote add origin <remote url>
After committing your changes, you can push the commits from your local machine to your remote repository on GitHub with the following command:
$ git push -u origin master
Enter the github username and password if it asks.
The final steps will look like
Perfect! The changes we made are now available in the remote repository on our GitHub profile.
That would be it. Happy Coding ProGrad ❤️!