DEV Community

Cover image for GITHUB
Frank
Frank

Posted on

GITHUB

GITHUB

GitHub is an online platform for version control and collaboration that allows developers to work on projects together. It uses Git, a distributed version control system, to track changes in code. With GitHub, you can manage your git repositories, collaborate with other developers, and deploy your projects. Git and GitHub work hand in hand, but they are distinct tools with different functions.

Suppose you want to work with your friends to create a new video game. You all own distinct talents and wonderful ideas. You are all highly skilled at coding the game's mechanics, for instance, and one of you is great at character design, another at developing the story, and so on.
If you and your team are working on a game, GitHub can be likened to an extremely well-organized notepad where you can take notes and track your progress. It facilitates collaboration amongst you all even if you're working from different places.


What is GitHub Used For?

  1. Version Control: Keep track of changes in your code and collaborate with others.
  2. Collaboration: Multiple people can work on the same project from anywhere.
  3. Code Hosting: Store your code in repositories.
  4. Project Management: Organize and manage your project tasks.
  5. Documentation: Write and host documentation in your repository.
  6. CI/CD Integration: Integrate with Continuous Integration/Continuous Deployment tools.
  7. Open Source Projects: Share your code with the world and collaborate with the open-source community.

Image description

How Has GitHub Helped Developers?

  1. Collaboration: It has made it easier for developers to collaborate on projects, whether they're in the same room or across the globe.
  2. Community: Developers can contribute to open-source projects, learn from others, and share their own projects.
  3. Efficiency: Features like pull requests, code reviews, and issues help streamline the development process.
  4. Visibility: Developers can showcase their work and build a portfolio.

How to Set Up a GitHub Account

Sign Up:
Go to GitHub's website.
You should see something like this

Image description

.  Click on "Sign up" and follow the instructions to create an 
       account.
Enter fullscreen mode Exit fullscreen mode

Set Up Git:

.  Download and install Git from [git-scm.com](‏https://git-scm.com/).
.  Configure Git with your username and email:
Enter fullscreen mode Exit fullscreen mode

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Create a Repository:
. After logging in to Github, locate the "+" button and click the drop down arrow. This is what you should see:

Image description

.  Fill in the repository name and other details.
.  Click on "Create repository".
Enter fullscreen mode Exit fullscreen mode

Clone a Repository:

.  Copy the repository URL.
.  Open a terminal and run:
Enter fullscreen mode Exit fullscreen mode

git clone https://github.com/username/repository.git

Image description

Create a File:
. Navigate to the Cloned Repository. Let's assume the cloned
repository is new_repo

cd repositoryname

Image description

   .  You can create a new file using a text editor or directly from 
      the terminal.
Enter fullscreen mode Exit fullscreen mode

echo "Your content here" > newfile.txt

Image description
To view the file you just write the command
ls

Image description

Check the Status:
. This command shows the status of your working directory and staging

git status

You should get a message like this

Image description

Add the File:
. This stages the new file for the next commit

git add filename.txt

Image description

Commit the File:
. This stages the new file for the next commit

git commit -m "Added newfile.txt"

You should see something like this

Image description

Push the Changes:
. This stages the new file for the next commit.

git push origin master

Image description

Now we've successfully created a file and pushed it to our GitHub, isn't that amazing?

Image description

You can find the new repository and file in the "Your Repository" tab; click on your profile picture; you should see that. You'll see the new file once you've clicked on the new repository you've created.

Image description

Image description

Image description


README FILE

In the field of software development, effective communication is important. Effectively communicating the goal, setup, and usage of your project is crucial, regardless of whether you work as a single developer or as a member of a large team.

Image description

A README file is a text file that provides essential information about a project, repository, or software package. It serves as an introductory guide for users and contributors, explaining the purpose, features, installation instructions, usage, and other relevant details of the project. The file is typically named README, often with an extension like .md (for Markdown format) or .txt (for plain text).

WHY SHOULD I HAVE A README FILE?

  • An excellent README distinguishes your project from others and should be as good as the product/project itself.

  • It will be the first thing people notice when they encounter your
    project, so keep it brief but thorough.

  • The quality of a README description distinguishes a good from a bad
    project.

  • Many times, README.md is hosted on a website; make sure your webpage is
    as cool as your project!

Key Components of a README File

  1. Include the Project Title: This is the name of the project. It provides the entire project in a few lines and helps people understand the main goal and aim.
  2. Description: Your description is a critical component of your project. A well-maintained description enables you to showcase your work to other developers and possible employers.
  3. Usage: Provide instructions and examples to help users and contributors use the project. This will make it easier for them to solve problems as they will always have a point of reference.
  4. Give Credits: If you worked on the project with a team, mention your teammates. You should also include their GitHub profiles.

Optionally, you can add this details to your README file as well

  • What exactly was your driving force? Why did you create this project?

  • Which challenge does the project solve? Or what does it do?

  • Why did you use specific technologies? Assuming your project has a lot
    of features, add them here.

  • Discuss some of the problems you experienced and the features you plan
    on adding in the future.

  • What comes next for the project?

  • Mention languages, frameworks, databases, and so on.

  • Include deployment URLs or any other necessary links.

What is a Personal Access Token ? (PAT)

Image description
A Personal Access Token (PAT) is a token used to authenticate with GitHub's API. It's an alternative to using a password and is often required for actions like pushing to a repository over HTTPS.
PAT is like a special key that proves you’re allowed to make changes to the game code stored on GitHub. Instead of using your password all the time, you use this key.

How to Generate a PAT:

  1. Log In: Log into your GitHub account.
  • Go to Settings: Click on your profile picture in the upper-right corner, then click on "Settings".
  1. Developer Settings: In the left sidebar, click on "Developer
    settings
    ".

Image description

  1. Personal Access Tokens: Click on beside the the drop down button "Personal access tokens", then "Tokens (classic)".

  2. Select Scopes: Select the scopes or permissions you want to grant this
    token.

  3. Generate Token: Click on "Generate token" and copy the token for use
    in your Git operations.

NOTE: You do not need a Personal Access Token (PAT) to clone a public repository on GitHub. Cloning a public repository can be done without authentication. However, for cloning private repositories or performing other actions that require authentication, you might need a PAT.


Image description

DIFFERENCE BETWEEN GIT AND GITHUB

Feature Git GitHub
Type Version control system Cloud-based platform for Git repositories
Primary Function Tracking changes in source code Hosting and managing Git repositories
Local/Remote Local (distributed) Remote (cloud-hosted)
Key Components Commit, branch, merge, repository Pull request, issue tracker, CI/CD, social features
Collaboration Primarily local, can be shared via protocols Enhanced collaboration through web interface
Tools Command-line, various GUIs Web interface, GitHub Desktop, integrations

TRY THIS !!!

Your task is to create a README.md file for the newly created repository. This README file should give essential details about the project, allowing others to easily grasp what the project is about.

Top comments (1)

Collapse
 
ivan_okafor_6160194c9d649 profile image
Ivan Okafor

Amazing content
Keep it up