├── notes ├── README.md ├── 0. Prerequisites │ └── README.md ├── 2. Version Control │ └── README.md ├── 1. Linux Commands │ └── README.md └── 3. Basic Workflow │ └── README.md ├── code_samples ├── sample.js ├── sample.c ├── sample.py └── README.md ├── slides └── Git & Github Preliminary Draft.pptx ├── README.md ├── advance stuff └── README.md └── installation.md /notes/README.md: -------------------------------------------------------------------------------- 1 | Notes originally from [this](https://github.com/kossiitkgp/git-workshop-2018) repository 2 | -------------------------------------------------------------------------------- /code_samples/sample.js: -------------------------------------------------------------------------------- 1 | function add_two_numbers(a,b) { 2 | const sum = a + b 3 | console.log(sum) 4 | } 5 | 6 | add_two_numbers(5,2) // expected result 7 -------------------------------------------------------------------------------- /slides/Git & Github Preliminary Draft.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kossiitkgp/git-and-github-workshop-2020/HEAD/slides/Git & Github Preliminary Draft.pptx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [YouTube video of the Seminar](https://youtu.be/8Hz8Sx8zLGw) 2 | 3 | # This issues were created to demonstrate while the workshop. This repo is not currently being maintained 4 | -------------------------------------------------------------------------------- /code_samples/sample.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int add_two_numbers(a,b) { 4 | int sum; 5 | sum = a + b; 6 | printf("%d", sum); 7 | } 8 | 9 | 10 | int main() { 11 | add_two_numbers(5,2); // expected result 7 12 | } -------------------------------------------------------------------------------- /code_samples/sample.py: -------------------------------------------------------------------------------- 1 | def add_two_numbers(a,b): 2 | ''' 3 | The function takes in 2 numbers and prints their sum 4 | 5 | Args: 6 | a,b : two real numbers 7 | ''' 8 | sum = a + b 9 | print(sum) 10 | 11 | add_two_numbers(5,2) # expected result 7 -------------------------------------------------------------------------------- /advance stuff/README.md: -------------------------------------------------------------------------------- 1 | Once you are pretty much comfortable with the contents of the workshop. Don't stop! There are many more useful and powerful features of git, which can improve development experience. 2 | Here is a list of such resources 3 | 4 | 0. [A simple handy git guide](https://rogerdudler.github.io/git-guide/), [Cheatsheet by Github](https://education.github.com/git-cheat-sheet-education.pdf) 5 | 1. [Pro Git book](https://git-scm.com/book/en/v2): A good book to get a deeper understanding of things 6 | 2. [Rebasing](https://youtu.be/f1wnYdLEpgI): An other powerful feature for a better workflow, helps updating your branch with the `main`(a frequent usecase) 7 | 3. [Squashing](https://www.internalpointers.com/post/squash-commits-into-one-git): When you send a PR, you don't want to have absurd number of commits, you can *simply* them into a single commit 8 | -------------------------------------------------------------------------------- /code_samples/README.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | The above sample files contain a bug as mentioned in the issue. Do fix a bug in the files which you 3 | can and send a PR to the this repository. Please make sure you write proper commits and commit messages. 4 | A good practice would be to have one commit for each bug fix, with an appropriate message. 5 | 6 | ## Instructions to send a PR 7 | 1. Before starting to work, you need to have a copy of this repo on your github- `Fork` it 8 | 2. After forking the repository, you have a copy of it in your repositories list on github. To bring that repo on your machine - `Clone` it 9 | 3. Once the codebase is one your machine, move to the directory. It is always a good idea to not experiment on `main` branch. Make a new branch - `git branch BRANCH_NAME` 10 | 4. Hop on to the branch you just created - `git checkout BRANCH_NAME` 11 | 5. Fix the bugs, add the files to the staging area, simplest way - `git add -A` (adds all the files in which changes are made) 12 | 6. Commit it along with a proper message - `git commit -m "A proper commit message which explains what you did in simple and short way"` 13 | 7. Push to the github - `git push origin BRANCH_NAME` (Note that you are pushing to the forked repository) 14 | 8. Open the forked repository on github, it shows you an option for sending a pull request. 15 | 9. Click on the button. 16 | 10. While sending a PR add a proper title and description so that the repo maintainer gets an idea of what the PR is about. It is always a good idea to mention the issue in the description of the PR. For example, if you are fixing issue number - 5, you can include `Fixes #5` 17 | -------------------------------------------------------------------------------- /notes/0. Prerequisites/README.md: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | Welcome all to this Git/GitHub workshop. 3 | 4 | 5 | ### What are we going to learn today? 6 | 7 | 1. Basic Linux Commands 8 | 2. Introduction to Version Control 9 | 3. Track your project using git 10 | 4. Contributing to a project 11 | 12 | ### Make your GitHub account: https://www.github.com. 13 | 14 | ## Windows: 15 | 16 | Follow the instructions on the blog: https://blog.kossiitkgp.in/using-git-bash-for-git-in-windows-d1876774fae3 || https://bit.ly/2RtFuaZ 17 | 18 | ## Mac: 19 | 20 | 1. Git comes preinstalled in the latest version of Mac. Execute `git --version` in the terminal. If a version number is obtained, Git is already present in your system. 21 | 2. Otherwise, Homebrew (http://brew.sh/) is an alternative to install Git. If you have Homebrew installed, you can install Git via 22 | 23 | `brew install git` 24 | 25 | ## Ubuntu: 26 | 27 | 1. Execute `git --version` in the command line. 28 | 2. If you get a valid version number, you have git already installed on your computer, else follow the instructions below. 29 | 30 | #### Install git 31 | 32 | 1. Execute the following command: `sudo apt install git`. Type your password when prompted which won't be visible to you. 33 | 2. Execute `git --version` in command line to verify installation. 34 | 35 | #### Configure git: 36 | 37 | 1. After you've installed git properly, it's time to set some variables for the git configuration. You've to do this only once. Follow the commands on terminal. 38 | 39 | * `git config --global user.name ""` 40 | * `git config --global user.email ""` 41 | * `git config --global http.proxy http://172.16.2.30:8080` // Setting system.proxy in git 42 | * `git config --global core.editor nano` 43 | 44 | 3. Now check `git config --list` to know you've set the variables correctly. 45 | 46 | 47 | Congratulations, you've git up and running on your computer. Now, it's time to start learning git. 48 | -------------------------------------------------------------------------------- /notes/2. Version Control/README.md: -------------------------------------------------------------------------------- 1 | ## Version Control System - VCS 2 | 3 | ### What is VCS and why do we need it? 4 | 5 | * Version control software keeps track of every modification to the source code in a special kind of database. 6 | * If a mistake has made, developers can turn back the clock and compare earlier versions of the code to help fix that mistake. 7 | * Especially useful when a project is being handled by a team usually in large code bases. 8 | * Examples for VCS are Git, Mercurial, SVN and many more. 9 | 10 | 11 | ### What would happen without VCS? 12 | 13 | 1. Make a copy of that file/folder once you made a new version. 14 | 2. Disadvatage of this is that it takes a lot of memory and the project will have a really bad structure. 15 | 16 | #### Real life example: 17 | 18 | ![meme](https://i.imgur.com/m3g6Plx.png) 19 | 20 | 21 | ### Types of Version Control Systems: CVCS and DVCS 22 | 23 | 1. Centralized Version Control System 24 | * The code is at a centre hub and all others access it from there. 25 | * If the central code get lost, the code get lost from all the linked computers. 26 | * Creating a new branch is costly as it involves making an entire copy of the original code. 27 | 28 | 2. Distributed Version Control System. 29 | * The central code is distributed to all the cloned repositories. 30 | * If the central code get lost, the others will still have access to the code through their clones. 31 | * Creating a new branch is easy and it only involves tracking the changes made. 32 | 33 | ### Git over other Version Controls? 34 | 35 | 1. Git has manual saving. 36 | 2. Git is distributed. 37 | 3. Keeps everything using least memory. 38 | 39 | > [Read more](https://mentormate.com/blog/differences-git-svn/) 40 | 41 | ### Where will git be used? 42 | 43 | 1. All the major Open source projects are hosted on GitHub. As the name says it's the hub of projects tracked using git. We hope you've understood the difference between git and GitHub by now. 44 | 2. Google Summer of Code, Rails Girls Summer of Code, Kharagpur Winter of Code and all Open source projects. 45 | [OpenSource-Projects](https://github.com/tapasweni-pathak/SOC-Programs) 46 | 3. Here the code is made public for people to see and is much more interactive. It enhances the community interaction. 47 | 48 | 49 | ### What is GitHub? 50 | GitHub is a web-based hosting service for version control using Git. It is mostly used for computer code. It offers all of the distributed version control and source code management functionality of Git as well as adding its own features 51 | 52 | ### Git vs GitHub. 53 | 54 | * Git is a DVCS. 55 | * GitHub hosts a large number of OS projects that are tracked using git. "Even git itself". 56 | * Git is a tool and Github is a service provider. 57 | 58 | ### Services which GitHub provides: 59 | 60 | 1. GitHub student pack. (Use your institute mail id to sign up) 61 | 2. GitHub pages. 62 | -------------------------------------------------------------------------------- /installation.md: -------------------------------------------------------------------------------- 1 | # GIT INSTALLATION GUIDE 2 | * ## LINUX INSTALLATION GUIDE 3 | Here are links to few installation guiding sites for installation of git bash on your linux system: 4 | 5 | https://git-scm.com/download/linux 6 | 7 | OR 8 | 9 | https://www.atlassian.com/git/tutorials/install-git#linux 10 | 11 | **NOTE**: make sure to check the installation of git on your system by running the following command on shell after installation process:- 12 | 13 | git --version 14 | 15 | `git --version` tells you the Git version currently installed on a system. It is also a confirmation that Git is installed. 16 | 17 | 18 | 19 | * ## WINDOWS INSTALLATION GUIDE 20 | Here are links to few installation guiding sites for installation of git bash on windows and getting started with it: 21 | 22 | https://phoenixnap.com/kb/how-to-install-git-windows 23 | 24 | OR 25 | 26 | https://www.stanleyulili.com/git/how-to-install-git-bash-on-windows/ 27 | 28 | **NOTE**: make sure to check the installation of gitbash on your system by running the following command on Windows Command Prompt or Powershell after clicking FINISH on installation process:- 29 | 30 | git --version 31 | 32 | `git --version` tells you the Git version currently installed on a system. It is also a confirmation that Git is installed. 33 | 34 | 35 | * ## MAC OS X INSTALLATION GUIDE 36 | Here are links to few installation guiding sites for installation of git bash on your MAC OS X system: 37 | 38 | https://git-scm.com/download/mac 39 | 40 | OR 41 | 42 | https://www.atlassian.com/git/tutorials/install-git#mac-os-x 43 | 44 | **NOTE**: make sure to check the installation of git on your system by running the following command on shell after installation process:- 45 | 46 | git --version 47 | 48 | `git --version` tells you the Git version currently installed on a system. It is also a confirmation that Git is installed. 49 | 50 | ### Now that you have installed git on your system, its time to create your own Github account to get started with using git and github. 51 | 52 | # GITHUB ACCOUNT CREATION GUIDE 53 | here are some links for step by step guide to create your own github account: 54 | 55 | Article: https://www.wikihow.com/Create-an-Account-on-GitHub 56 | 57 | OR 58 | 59 | Video tutorial: https://www.youtube.com/watch?v=2NxsjFtGjBA 60 | 61 | # LINKING/CONFIGURING GIT AND GITHUB 62 | Once the installation has successfully completed, the next thing to do is to set up the configuration details of the GitHub user. To do this use the following two commands by replacing "user_name" with your GitHub username and replacing "email_id" with your email-id you used to create your GitHub account. 63 | 64 | 65 | 66 | git config --global user.name "user_name" 67 | git config --global user.email "email_id" 68 | The following image shows an example of my configuration with my "user_name" being "akshaypai" and my "email_id" being "abc123@gmail.com" 69 | 70 | ![Image of CONFIG CONSOLE](https://www.howtoforge.com/images/ubuntu_github_getting_started/config.png?ezimgfmt=rs:550x104/rscb1/ng:webp/ngcb1) 71 | #### Now you are ready for the workshop!!🚀🚀 72 | #### See you in session...👩‍💻👨‍💻 73 | -------------------------------------------------------------------------------- /notes/1. Linux Commands/README.md: -------------------------------------------------------------------------------- 1 | # Basic linux commands: 2 | 3 | ### Why use command line? 4 | Using a command line increases your programming speed and it never let your system hang. 5 | 6 | ex: Try to create a folder 'c' inside 'b' inside 'a'. 7 | 8 | Let's try it using command line: 9 | 10 | `mkdir -p a/b/c` 11 | 12 | ### More commands: 13 | 14 | * `cd ` : Changes your location to given directory. 15 | * `mkdir ` : Makes a new directory at the current path. 16 | * `rmdir ` : Deletes the given directory. 17 | 18 | **Note**: 19 | 20 | > `cd` : Locate to home directory. 21 | >`cd ..` : Locate to previous directory. 22 | * `pwd` : Gives the absolute path of the current directory. 23 | * `ls` : List the files/directories in the current folder. 24 | * `ls -a` : Gives the list of all the files/directories(including the hidden files/directories). 25 | * `mv ` : Change the location of a file/directory. 26 | * `touch ` Create a new file in the directory. 27 | * `rm ` Deletes given file. 28 | * `cat ` Display the contents of the file on the terminal. 29 | * `sudo apt-get install ` Install a package using command line. 30 | 31 | **Note**: ` --help` to get all use cases of the command 32 | 33 | ### Why is Linux preferred over Windows? 34 | 35 | * Open source nature: 36 | > What is it like when you buy a car, but you cannot see what’s under the hood? Similar is the case with when you use a Windows-powered system. 37 | 38 | > However, in contrast, Linux is completely an open source project. You can have a look at the source code of a Linux OS, which is a plus. 39 | [(1)](https://i.imgur.com/tJ2JEVb.jpg) 40 | 41 | * Secure: 42 | > Windows OS is vulnerable to different types of attacks (or hacks). However, Linux is not as vulnerable as Windows. It sure isn’t invulnerable, but it is a lot more secure. Although, there’s no rocket science in it. 43 | 44 | * Can revive older computers: 45 | > As the operating systems evolve, so do their hardware requirements increase exponentially. For instance, if you purchase a genuine copy of Windows 10, you will have to meet the minimum hardware requirements to run it successfully, and you cannot run it on just about any low-end system. 46 | 47 | * Perfect For Programmers 48 | > GNU/Linux is a Unix-like OS. It has a huge collection of programs which makes your command line lit. It can increase your programming speed to a great extend. Comes with most of the things installed by default. All the configurations can be easily done using certain package managers. You don't have to make your hands dirty and waste huge amount of time in just installing and configuring programs to make them work. 49 | 50 | * Software Updates 51 | > You'll be getting regular software updates and bug fixes. Even when you mess something up, you can send an error report to get it fixed soon. Unlike Windows or other proprietary operating systems, it has a huge community support. 52 | 53 | * Many more 54 | > It comes with better privacy management, customisations, freedom, huge number of distros depending upon your needs, etc. 55 | 56 | ### What is Open source? 57 | 58 | Open source software is software with source code that anyone can inspect, modify, and enhance. 59 | 60 | "Source code" is the part of software that most computer users don't ever see; it's the code computer programmers can manipulate to change how a piece of software—a "program" or "application"—works. Programmers who have access to a computer program's source code can improve that program by adding features to it or fixing parts that don't always work correctly. 61 | -------------------------------------------------------------------------------- /notes/3. Basic Workflow/README.md: -------------------------------------------------------------------------------- 1 | # Let's start your journey with Git. 2 | 3 | ### 1. Creating a local repository. (Git command: git init) 4 | - Simply cd into the directory you want to track and type `git init`. This will create a `.git` folder in the directory with a basic skeleton without any commits. 5 | 6 | ### 2. Checking files which can be commited. (Git command: git status) 7 | >`$ git status` 8 | - This will list the files that have been changed in red and those which can be commited in green 9 | 10 | - To ignore files that you dont want to track create a `.gitignore` file using `touch .gitignore` 11 | - Open this using text editor and add names of files you want to ignore. 12 | 13 | ### 3. Staging Area. 14 | - Moving files to staging area: 15 | - For adding files individually use 16 | > `$ git add ` 17 | - For adding all files at once use 18 | > `$ git add -A` 19 | - To remove files from staging area use 20 | > `$ git reset ` 21 | - and to remove all simply type 22 | > `$ git reset` 23 | 24 | ### 4. To track the changes you made: 25 | > `$ git diff` 26 | 27 | ### 5. To commit the files: 28 | > `$ git commit` 29 | - but it is necessary to add messages with the commit to make sure what we did ; so for that we use `-m` extension like `git commit -m “message”` 30 | - You can also compare the changes you made w.r.t a commit using `git diff `.If `` field is kept empty, git will compare it with the last commit. 31 | 32 | ### 6. To check the commit history: 33 | >` $ git log` 34 | 35 | >` $ git log --graph` presents the change history in the tree format. 36 | 37 | ### 7. Creating a repository on GitHub. (Git command: git remote) 38 | >`$ git remote add origin ` 39 | - and to update it use `git push origin master`(explained later). 40 | 41 | ### 8. Uploading your changes to Github: 42 | - We use `git push origin ` to upload the changes to Github. 43 | - But before pushing it back we need to pull and check whether any other person made a change in the branch since the last time type in `git pull origin master` ( If on master branch else use branch name in place of master). 44 | 45 | ##### Congrats you made your first commit! 46 | 47 | ### 9. Fetching changes without merging 48 | - `pull` fetches the changes and merges it in directly to the branch you are in. That may cause some problems if there are conflicts. Instead, it's better to use `fetch`. 49 | - `fetch` does exactly what it says. It fetches commits from a repo/branch and you can either merge it or inspect it by checking out to that branch. 50 | 51 | ### 10. Branching: 52 | - To create a new branch use `git branch ` 53 | - To check all the branches present use `git branch` 54 | - To switch over branch use `git checkout ` 55 | - To do the above processes of creating and switching together use `git checkout -b ` 56 | - To push a commited changes type in `git push -u origin ` 57 | - To merge the current branch you are working on to master use `git merge ` 58 | - To push the changes we simply use `git push origin master` 59 | - To check it they are merged type in `git branch --merged` 60 | - If the branch is successfully merged we can now delete the branch–`git branch -d ` 61 | 62 | ### 11. Switching to previous commit version (Extreme Situations): 63 | 64 | - We do `git reset --hard ` . Remember all code changes will be lost after this commit number. 65 | - If we do `git reset ` . It will reach to a state where the changes made after the commit number were still to added to the staging area. 66 | 67 | #### Pull Request: 68 | - Send a pull request to sandbox repository. 69 | --------------------------------------------------------------------------------