diff --git a/Advance-Git.md b/Advance-Git.md new file mode 100644 index 0000000..d4a82dc --- /dev/null +++ b/Advance-Git.md @@ -0,0 +1,8 @@ +# Generate and Add SSH Keys to GitHub + +1. Generate SSH Keys: [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) +2. Add SSH Keys to GitHub: [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) +3. Test Your SSH connection: [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/testing-your-ssh-connection) + + + diff --git a/Branches.md b/Branches.md new file mode 100644 index 0000000..b00ee94 --- /dev/null +++ b/Branches.md @@ -0,0 +1,81 @@ +# Branches + +Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion. + +A **branch** could be interpreted as an individual timeline of our project commits. + +With Git, we can create many of these alternative environments (i.e. we can create different **branches**) so other versions of our project code can exist and be tracked in parallel. + +That allows us to add new (experimental, unfinished, and potentially buggy) features in separate branches, without touching the '_official'_ stable version of our project code (which is usually kept on the **master** branch). + +When we initialize a repository and start making commits, they are saved to the **master** branch by default. + +## Creating a new branch + +You can create a new branch using the following command: + +```bash +git branch +``` + +The new branch that gets created will be the reference to the current state of your repository. + +\ +📌 It's a good idea to create a **development** branch where you can work on improving your code, adding new experimental features, and similar. After development and testing these new features to make sure they don't have any bugs and that they can be used, you can merge them to the master branch. + +## Changing branches + +To switch to a different branch, you use the **git checkout** command: + +```bash +git checkout +``` + +With that, you switch to a different isolated timeline of your project by changing branches. + +\ +📌 For example, you could be working on different features in your code and have a separate branch for each feature. When you switch to a branch, you can commit code changes which only affect that particular branch. Then, you can switch to another branch to work on a different feature, which won't be affected by the changes and commits made from the previous branch. + +To create a new branch and change to it at the same time, you can use the **-b** flag: + +```bash +git checkout -b +``` + +ℹ️ To list the branches for your project, use this command: `git branch` + +To go back to the **master** branch, use this command: + +## Merging branches + +You can merge branches in situations where you want to implement the code changes that you made in an individual branch to a different branch. + +For example, after you fully implemented and tested a new feature in your code, you would want to merge those changes to the stable branch of your project (which is usually the default **master** branch). + +To merge the changes from a different branch into your current branch, you can use this command: + +```bash +git merge +``` + +You would replace `` with the branch that you want to integrate into your current branch. + +## Deleting a branch + +To delete a branch, you can run the **git branch** command with the **-d** flag: + +```bash +git branch -d +``` + +ℹ️ Read more about branching and merging [on this link](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging). + +## Further learning + +To learn more about Git, make sure to check the following resources: + +- Git official documentation: https://git-scm.com/doc +- The free **Pro Git** book: https://git-scm.com/book/en/v2 +- Learn about GitHub: https://guides.github.com/ + +ℹ️ GitHub is a website where we can store our repositories online. In other words, GitHub works with Git as a repository hosting service. diff --git a/Git-Cheatsheet.pdf b/Git-Cheatsheet.pdf new file mode 100644 index 0000000..6f46294 Binary files /dev/null and b/Git-Cheatsheet.pdf differ diff --git a/README.md b/README.md index 149616e..ee3a8c2 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,246 @@ -Assuming you all are using Windows 10. +

Git and GitHub

-# Get Started +

+ +

-1. Install Git from the [official website](https://git-scm.com/downloads). -2. Create a GitHub account, if you don't have one already. +## Index + +- [To send changes to your remote repository](#to-send-changes-to-your-remote-repository) + - [Ignoring files](#ignoring-files) + - [Important Points to Remember](#important-points-to-remember) + - [Resources](#resources) + - [What's Next?](#whats-next) + - [Activity](#activity) + +## What is [Git](https://git-scm.com/) + +Git is a [distributed](https://git-scm.com/about/distributed) version control system (VCS). It's a system that keeps a record of changes to our project files over time. It enables us to record project changes and go back to a specific version of the files, at any given point in time. This system can be used by many people to efficiently work together and **collaborate on team projects**, where each developer can have their own version of the project, distributed on their computer. Later on, these individual versions of the project can be merged and adapted into the main version of the project. + +Basically, it's a massively popular tool for coordinating parallel work and managing projects among individuals and teams. Needless to say, knowing **`how to use Git is one of the most important skills for any Software Developer nowadays`** - and it's definitely a great addition to your resume! + +## What is [GitHub](http://github.com)? + +GitHub is a hosting platform for Git repositories. You can use Git on its own without Github (and other similar platforms), but it's difficult without github to collaborate or share your code with others. + +- **Git is the version control system, the tool that tracks changes to our files over time** +- **Github is a hosting service for projects that use Git.** + +Using _GitHub_, we can upload a local project repository to a remote cloud-based GitHub repository. We can also interact with public repositories published by other developers. + +ℹ️ GitHub could even be looked at as a social networking website for developers. Users can follow each other, give ratings, share or fork, like code via stars, comment via issues, collaborate and communicate. + +GitHub allows developers to utilize, change or improve software from its repositories. Each repository contains all project files and the code history. Repositories can have multiple collaborators and can be either public or private. + +GitHub is also a popular way developers to publish their project portfolio online. It's an easy way to showcase skills and experience to potential employers or clients. It's an important technology to be familiar with, especially for a new developer who is just starting out. + +### Features of Git and Github + +1. **Version Control:** Git keeps a record of every change you make to your project, so it has the ability to remember every change you make to your code. It's like time-travel! So, if you make a mistake you can easily go back to a previous version if you need to. + +1. **Sharing with Friends:** You can share your code with your friends or anyone around the world, and they can marvel at your creations, give suggestions, take inspiration, or even add their own touches to your works. + +1. **Collaboration:** . Multiple people can work together on the same project simultaneously, and Git helps merge everyone's work seamlessly and makes it effortless for everyone to contribute their parts. + +1. **Backup:** Git Repository ensures safety and protects your work from getting lost or damaged. Even if your computer misbehaves, your projects are securely stored and can be accessed from another computer. + +### What is a Repository + +**A Git repository is a container for a project that is tracked by Git.** -# Configure Git +Imagine a repository as a special place that stores your creative project, just like a treasure chest for your computer code and files. Git repository is a magical box that keeps track of every change you make to your code and files over time. The Repository is like your personal storage area in the digital world. It helps you keep track of your code, artworks, or any other digital wonders you create. Instead of saving your work scattered all over your computer, you place everything inside this repository. -Open Git Bash and type the commands given below to configure it. Enter your information inside the quotation marks. +We can single out two major types of Git repositories: + +- **Local repository** - an isolated folder stored on your own computer, where you can work on the local version of your project. +- **Remote repository** - generally stored outside of your isolated local system, usually on a online server i.e [github.com](https://github.com). It's especially useful when working in teams, this is the place where you can share your project code, see other people's code and integrate it into your local version of the project, and also push your changes to the remote repository. + +### What are CLI Tools + +CLI (command-line interface) allows you to interact with a computer using text-based commands instead of relying on Graphical user interfaces (GUIs), the CLI provides a powerful and efficient way to perform various tasks and operations directly from the Terminal also called shell. All terminals work almost similarly, CLI tools offer efficiency, flexibility, and scripting capabilities, making them powerful resources for developers, system administrators, and tech-savvy users. + +Types of terminals: + +- Bash +- Command prompt or CMD +- PowerShell + +Git is a CLI Tool, which we can access with our system terminals. **🔴 All commands will be ran on the root of the project source directory**. + +### Git status + +To check the current status of repo. + +```bash +git status ``` -git config --global user.name "Your Name" + +## [Staging files](https://git-scm.com/about/staging-area) + +We can use the **git add** command to add our files to the staging area, which allows them to be tracked. + +We can add a specific file to the staging area with the following command: + +```bash +git add file.js +``` + +To add multiple files, we can do this: + +```bash +git add file.js file2.js file3.js +``` + +Instead of having to add the files individually, we can also add all the files inside the project folder to the staging area: + +```bash +git add . +``` + +By default, this adds **all the files and folders** inside the project folder to the staging area, from where they are ready to be committed and tracked. + +## Commits + +`git add` will stage the files that will be part of my commit + +A **commit** is a snapshot of our code at a particular time, which we are saving to the commit history of our repository. Commit is like page in history book that has its own unique id and can never be changed. + +After adding all the files that we want to track to the staging area with the **`git add`** command, we are ready to make a commit. + +To commit the files from the staging area, we use the following command: + +```bash +git commit -m "Commit message" ``` + +Inside the quotes, we should write a **commit message** which is used to identify it in the commit history. + +The commit message should be a descriptive summary of the changes that you are committing to the repository. + +After executing that command, you will get the technical details about the commit printed in the terminal. And that's basically it, you have successfully made a commit in your project! + +you can see Commit history on github.com + +## Get Started with Git + +1. Install Git from the [official website](https://git-scm.com/downloads). +1. If everything went well, it should return the Git version that is installed on your computer. +1. If you don't have already Sign up for an account at [github.com](https://github.com/signup). +1. Once inside, you'll find your own Repositories. +1. Create a new project or artwork by simply clicking the `New` button and giving it a unique name. +1. To initialize a local repository and start tracking your project, in terminal and navigate to the main folder of your project, then type `git init`. This command will generate a hidden `.git` folder in your project, where Git stores all internal tracking data for the current repository. We don't need to look and change in .git. +1. Keep your repos public and share your code with world. +1. Add your digital creations to the repository – your code, documents, images, or anything you create! + +## Configure Git + +Open Terminal and type the commands given below to configure it. Replace the values inside the quotes with your name and email address. + +```bash +git config --global user.name "Your Name" ``` + +```bash git config --global user.email "yourname@example.com" ``` GitHub recently changed the default branch on new repositories from master to main, change the default branch for Git using this command: -``` +```bash git config --global init.defaultBranch main ``` To verify things are working properly, enter these commands and verify that the output matches your name and email address: +```bash +git config --list ``` -git config --get user.name + +YOU ARE READY TO GO! + +### Basic Commands + +To copy a github repo to your computer + +```bash +git clone ``` + +```bash +git add . ``` -git config --get user.email + +```bash +git commit -m "my message" ``` -# Generate and Add SSH Keys to GitHub +# To send changes to your remote repository -1. Generate SSH Keys: [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) -2. Add SSH Keys to GitHub: [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) -3. Test Your SSH connection: [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/testing-your-ssh-connection) +```bash +git push origin main +``` -#### VOILA! YOU ARE READY TO GO! +If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with -# Learn Basic Git Commands +```bash +git remote add origin +``` + +To update your local repository to the newest commit, execute + +```bash +git pull +``` + +## [Ignoring files](https://help.github.com/en/articles/ignoring-files) -Video: [Learn Git In 15 Minutes](https://www.youtube.com/watch?v=USjZcfj8yxE)
-Notes: [Notion Notes](https://www.notion.so/zarkom/Introduction-to-Git-ac396a0697704709a12b6a0e545db049) +To ignore files or folders that you don't want to be tracked or added to the staging area, you can create a file called `.gitignore` in your main project folder. Inside of that file, you can list all the file and folder names that you definitely do not want to track +## Important Points to Remember -# Learn Basics of GitHub +1. Repository is just a folder in Git. +1. Always make a repo before starting to code. +1. Keep committing code after finishing ever feature. +1. Make a Pull Request after your work is done. +1. Never close your computer without pushing code to Github. +1. Keep you commit messages relevant to your feature. -Video: [Learn GitHub in 20 Minutes](https://www.youtube.com/watch?v=nhNq2kIvi9s)
-Notes: [Notion Notes](https://www.notion.so/zarkom/Introduction-to-GitHub-202af6f64bbd4299b15f238dcd09d2a7) +## Resources -# What's Next? +| | | +| --- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| 1. | [Complete Git Course (Basic to Advance) by Sir Zeeshan in Urdu](https://www.youtube.com/playlist?list=PLKueo-cldy_HjRnPUL4G3pWHS7FREAizF) | +| 2. | [Git - the simple guide Article](https://rogerdudler.github.io/git-guide/) | +| 3. | [Visualizing Git Tool](https://git-school.github.io/visualizing-git) | +| 4. | [GitHub Education's cheat sheet for commonly used git commands.](./git-cheatsheet.pdf) | +| 5. | [Learn Basic Git Commands](https://www.youtube.com/watch?v=USjZcfj8yxE) | +| 6. | [Learn Basics of GitHub](https://www.youtube.com/watch?v=nhNq2kIvi9s) | +| 7. | [Fireship teaching Git in 12min](https://youtu.be/HkdAHXoRtos) | + +### What's Next? After learning the basic commands, dive deep into the following: 1. Cloning a repo -2. Forking a repo -3. Difference between cloning and forking -4. Difference between origin and upstream -5. Branches -6. Merge Conflicts -7. Pull Requests (Although we will work as collaborators instead of contributors but PR is an important concept to learn.) +1. Forking a repo +1. Difference between cloning and forking +1. Difference between origin and upstream +1. Branches +1. Merge Conflicts +1. Pull Requests -# Activity +### Activity Doing this small activity will give you a hands-on experience and help cement your knowledge: 1. Fork this very repo. -2. Clone it on your local machine. -3. Create a new branch . -4. Edit README, add a new line and write, ": I did it!". -5. Commit the changes to your local repo. -6. Push the code to your remote repo (the forked one). -7. Send a pull request to me so I can accept your changes in this original repo. - -\ -**Note:** -I have included GitHub Education's Git cheat sheet in the repo that contains some commonly used git commands. You can view it here: [git-cheatsheet.pdf](git-cheatsheet.pdf). +1. Clone it on your local machine. +1. Create a new branch . +1. Edit README, add a new line and write, ": I did it!". +1. Commit the changes to your local repo. +1. Push the code to your remote repo (the forked one). +1. Send a pull request to me so I can accept your changes in this original repo. --- -### If you find the repo useful, do support it by giving a star. ⭐ -## 🖋 Author -Follow my GitHub profile to stay updated with my latest projects: - -[![Follow codesnerd on GitHub](https://img.shields.io/badge/Connect-codesnerd-blue.svg?logo=Github&longCache=true&style=social&label=Follow)](https://github.com/codesnerd) - -## 👍 Acknowledgements -* Videos and notes by [Colt Steele](https://www.youtube.com/c/ColtSteeleCode) +

Show some ❤️ by this repository

diff --git a/docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..28e1976 --- /dev/null +++ b/docs/CODE_OF_CONDUCT.md @@ -0,0 +1,5 @@ +# Code Of Conduct + +1. Make sure text in [easy to follow steps to push code](../easy-to-follow-steps.md) is concise. + + (Concise means giving a lot of information clearly and in a few words; brief but comprehensive.) diff --git a/easy-to-follow-steps.md b/easy-to-follow-steps.md new file mode 100644 index 0000000..ae958da --- /dev/null +++ b/easy-to-follow-steps.md @@ -0,0 +1,95 @@ +# Git and Github + +These are easy to follow steps to push code to github. (for theory of git [visit this page](./README.md)) + +1. Install Git from the [git-scm.com/downloads](https://git-scm.com/downloads). + + ![git scm website](./images/git-scm.png) + +1. In terminal `git --version` command should return the Git version that is installed on your computer. + +1. Type this in terminal with your credentials. + + ```bash + git config --global user.name "Shehzad Iqbal" + + git config --global user.email "shehzaddiqbal@gmail.com" + ``` + +1. If you don't have already `Sign up` for an account at [github.com](https://github.com/signup). + + (First 4 steps are only required one time) + +1. Create a new repo on github.com simply by clicking the `New` button and giving it a unique name or visit [github.com/new](https://github.com/new). + +1. Keep your repo public and leave other options as it is. + +1. Copy http link below green `Code` button + + ![code link button](./images/code-link.png) + + OR + + ![new repo code link button](./images/code-link-new.png) + +1. Run this command in new folder + + ```bash + git clone + ``` + +1. This command will generate a hidden `.git` folder in your project, where Git stores all internal tracking data for the current repository. We don't need to look and change in .git. **All files next to `.git` folder will be pushed!** + +1. Navigate in the Folder with + + ```bash + cd folderName + ``` + +1. Open VS Code with `code .` command and Create a files name `index.html`. + +1. Then to add files and push code run these commands in your project. + + ```bash + git add . + ``` + + ```bash + git commit -m "my message" + ``` + + ```bash + git push origin main + ``` + +1. Your terminal should look like this + + ![new repo code link button](./images/terminal.png) + and your code should be next to `.git` folder. + + ![new repo code link button](./images/repo.png) + +1. Add your digital creations to the repository – your code, documents, images, or anything you create and keep evolving! + +## Common problems + +1. Not giving space in commands like + + ```bash + git commit-m "my message" + ``` + +1. `nothing to commit` error mean your folder with `.git` is either empty or code has already being pushed. + +1. `fatal: not a git repository` error comes when you are in folder where git is not initialized i.e there is no `.git` folder. + +## [Learning Git Repo by Shehzad](https://github.com/shehza-d/teaching-git) + +## [Complete Git Course (Basic to Advance)](https://www.youtube.com/playlist?list=PLKueo-cldy_HjRnPUL4G3pWHS7FREAizF) + + diff --git a/git-cheatsheet.pdf b/git-cheat-sheet-education.pdf old mode 100644 new mode 100755 similarity index 100% rename from git-cheatsheet.pdf rename to git-cheat-sheet-education.pdf diff --git a/hosting-on-gh-pages.md b/hosting-on-gh-pages.md new file mode 100644 index 0000000..9c64f75 --- /dev/null +++ b/hosting-on-gh-pages.md @@ -0,0 +1,35 @@ +# Hosting on Github Pages + +Hosted directly from your GitHub repository. Just edit, push, and your changes are live. + +Github pages provide free and unlimited hosting for static html sites. + +1. First make sure your repo is Public + +1. Your repo has index.html file in root of project. + + ![Repo structure](./images/repo-face.png) + (If you index.html file is in folder or I is capital of Index.html hosting will not be successful) + +1. Then go to repo `setting` > `pages` and under branch heading click none and select `main` and don't forget to save. + + ![pages setting](./images/repo-setting-pages.png) + +1. Wait for 5 to 10 minutes and refresh the page to get the hosted link. + + ![hosted-link](./images/hosted-link.png) + +1. Congratulations! 🎉 you have successfully hosted your Web page. + + You can visit you Web page by clicking the link highlighted in above image. + +1. Suggestion: Copy the link and add it to your repos description. + + On home page click in button + ![repo about](./images/repo-about.png) + +1. And paste your hosted in in Website input (it's better to add description as well) and click save + + ![repo description](./images/repo-description.png) + +## [More About GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages) diff --git a/i.html b/i.html new file mode 100644 index 0000000..a983056 --- /dev/null +++ b/i.html @@ -0,0 +1,16 @@ + + + + + + Awesome website + + +

My Awesome website

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti, fuga! + Fuga debitis, esse veritatis deleniti consectetur tempora illo sit quasi + possimus maiores tenetur a eius, totam iusto quisquam cum nulla. +

+ + diff --git a/images/code-link-new.png b/images/code-link-new.png new file mode 100644 index 0000000..a407b4a Binary files /dev/null and b/images/code-link-new.png differ diff --git a/images/code-link.png b/images/code-link.png new file mode 100644 index 0000000..f18b2ef Binary files /dev/null and b/images/code-link.png differ diff --git a/images/git-scm.png b/images/git-scm.png new file mode 100644 index 0000000..a636d73 Binary files /dev/null and b/images/git-scm.png differ diff --git a/images/hosted-link.png b/images/hosted-link.png new file mode 100644 index 0000000..13966a8 Binary files /dev/null and b/images/hosted-link.png differ diff --git a/images/other/image2.png b/images/other/image2.png new file mode 100644 index 0000000..dfc4d50 Binary files /dev/null and b/images/other/image2.png differ diff --git a/images/other/repo-face1.png b/images/other/repo-face1.png new file mode 100644 index 0000000..1cadfe2 Binary files /dev/null and b/images/other/repo-face1.png differ diff --git a/images/other/repo-face222.png b/images/other/repo-face222.png new file mode 100644 index 0000000..2848c6c Binary files /dev/null and b/images/other/repo-face222.png differ diff --git a/images/repo-about.png b/images/repo-about.png new file mode 100644 index 0000000..406676e Binary files /dev/null and b/images/repo-about.png differ diff --git a/images/repo-description.png b/images/repo-description.png new file mode 100644 index 0000000..5966fc4 Binary files /dev/null and b/images/repo-description.png differ diff --git a/images/repo-face.png b/images/repo-face.png new file mode 100644 index 0000000..a2cca78 Binary files /dev/null and b/images/repo-face.png differ diff --git a/images/repo-setting-pages.png b/images/repo-setting-pages.png new file mode 100644 index 0000000..df9914f Binary files /dev/null and b/images/repo-setting-pages.png differ diff --git a/images/repo.png b/images/repo.png new file mode 100644 index 0000000..425e880 Binary files /dev/null and b/images/repo.png differ diff --git a/images/terminal.png b/images/terminal.png new file mode 100644 index 0000000..d90c593 Binary files /dev/null and b/images/terminal.png differ