Register GitHub as the development side

GitHub was usually mostly about cloning Git and using useful projects. Today, I decided to learn about some other useful features. Sign up at the following official page.

https://github.com/

Since the page that appears immediately after signing up for GitHub prompts you to create a repository, we assume that this is the recommended first step to start a project using GitHub or to migrate an existing project to GitHub. So, start by creating a repository. Even if you don’t plan to work on a specific project yet, it is beneficial to create a repository and familiarize yourself with basic GitHub usage. There are many purposes for adding repositories to GitHub, but the two main purposes are

Publish and share source code

GitHub is a widely used platform for publishing and sharing the source code of software development projects with other developers. For open source projects, publishing source code allows them to accept contributions from developers around the world. It is also used for personal projects and portfolios as a place to showcase and share one’s work with others.

Integration with External Services

GitHub provides a foundation for automating and streamlining development processes such as deployment, CI/CD (Continuous Integration/Continuous Delivery), testing, and monitoring through integration with external services such as Cloudflare Pages, Netlify, and Heroku Cloudflare Pages: Static sites.

  • Cloudflare Pages: A service that specializes in deploying static sites and front-end applications that can be automatically built and deployed by simply pushing them to a GitHub repository. Security and performance optimizations are also provided automatically.
  • Netlify: A hosting service for static sites and serverless functions that allows you to deploy your site directly using the GitHub repository. It has many developer-friendly features, such as customizing the build process and providing preview URLs.
  • Heroku: A more general-purpose application hosting platform that allows automated deployment of applications using GitHub repositories as the source. It is also suitable for backend application deployment.

These services can work with GitHub repositories to simplify the development flow and automate the deployment process. They also automatically build and deploy each time changes are made to the code in the repository, ensuring that it is always up-to-date. This allows developers to focus on creating and improving code, greatly reducing operational effort. I decided to take this opportunity to write this article because of the possibility of publishing my source code and because I may need it for Cloudflare Pages.

Registering or creating a repository means creating a dedicated repository for your project. To better understand and explain this process, we will go through it step by step, starting with the basics.

What is a Repository?

A repository is a place to store files and directories (folders) of a project. This includes source code, images, documentation, and anything else related to the project. The main reason for using a repository is to enable version control. By maintaining a repository using a version control system (e.g., Git), you can keep track of changes to files, go back to previous versions as needed, and see which changes were made, when, and by whom.

Local and Remote Repositories

  • A local repository is a repository that resides on your computer. Development work is done in this local repository, where files are added, changed, and committed (changes are recorded).
  • A remote repository is a repository hosted on a server on the Internet, such as GitHub, GitLab, or Bitbucket. The main purpose of using a remote repository is to back up your project, share code among team members, and collaborate.

What is registering (creating) a repository?

Registering (creating) a repository means creating a new storage location for your project. Specifically, it involves the following steps

  1. Creating a local repository: This means creating a new directory (folder) on your computer and running the git init command in it to put the directory under Git version control.
  2. Creating a remote repository: This involves creating a new repository on a service such as GitHub. This is done primarily through the web interface.
  3. Linking local and remote repositories: Synchronize these two repositories by “pushing” changes (commits) from the local repository to the remote repository. This allows the remote repository to serve as a backup for the project and to be shared with team members.

Even if, like me, you are working on a project alone, there are significant advantages to creating a repository and using version control. Below are some of the main advantages of using a repository for a personal project

Change History Management

A repository allows you to keep track of the changes you have made to each file in your project. This makes it clear what was changed and when, and makes it easy to revert to previous versions if necessary. It also helps you understand when and why certain changes were made.

Secure Backups

By linking local and remote repositories (e.g., on GitHub), you can easily create backups of your projects. This protects your projects from the risk of computer failure and data loss.

Efficient Change Management

Branches can be used to separate work when developing new features or fixing bugs. This allows you the freedom to try out new ideas while keeping the main development line stable. Once the work is complete, the changes can be integrated (merged) into the main project.

Publish and Share Projects

If you have the possibility to collaborate with other developers in the future, or if you want to publish your project as a portfolio, you may find it useful to use a remote repository. feedback from other developers.

Automation and Collaboration

Many development tools and services work in conjunction with repository hosting services such as GitHub. This allows them to automate many aspects of the development process, including automated code testing, deployment, and documentation generation.

Conclusion

Even if you are working on an individual project, a repository and version control system can make your development process more efficient and secure. It can be a very effective tool in growing and maintaining your project, as it allows you to track change history, provide secure backups, and prepare for future sharing and collaboration.

We will actually create a new repository. You will then see the commands in the top and bottom rows.

There are slight differences between both sets of commands, but which one you use depends on your current situation and objectives. Below are descriptions and usage scenarios for each command set.

Upper command set

This set includes a series of processes starting with initializing a new Git repository, creating a README.md file, staging it, committing it, and finally pushing it to GitHub. This set is suitable for starting a new project, where no repository exists locally yet.

  1. echo "# test" >> README.md: create a new README.md file or add text to an existing file.
  2. git init: initialize a new Git repository in the current directory.
  3. git add README.md: add the README.md file to the staging area.
  4. git commit -m "first commit": commits the staged changes.
  5. git branch -M main: rename the default branch to main.
  6. git remote add origin https://github.com/superdoccimo/test.git: add the GitHub repository URL as remote.
  7. git push -u origin main: pushes the local main branch to GitHub and sets origin main as the default upstream from then on.

Lower command set

This set contains only the commands to add the GitHub repository URL as remote, change the branch name to main, and push to GitHub. This set is appropriate if your Git repository has already been initialized locally, or if you have already added files or made your first commit.

  1. git remote add origin https://github.com/superdoccimo/test.git: Add the URL of the GitHub repository as a remote.
  2. git branch -M main: rename the default branch to main.
  3. git push -u origin main: pushes the local main branch to GitHub and sets origin main as the default upstream from then on.

Which should I use?

  • For new projects: use the upper command set. This will complete the sequence from initializing the repository to pushing to GitHub.
  • If you already have a local repository and have done some initial file additions and commits: the bottom set of commands is sufficient. This will set up the remote repository and perform the initial push.

To use Git on Windows, you must first install Git. After installation, commands using Git can be executed at the command prompt, in PowerShell, or with Git Bash (included in Git for Windows). The specific steps are as follows

1. Install Git

  • Download the installer for Windows from the official Git website ( https://git-scm.com/) and follow the instructions.

2. Prepare a folder to create a repository

  • Create a new folder for your project or use an existing project folder. This folder will be the root directory of the Git repository.
  • For example, if you want to start working with a folder called C:\Projects\MyProject, first create that folder, then navigate to it at the command prompt or with Git Bash.
    C:\Projects\MyProject

3. Running the command

  • Once you are in the folder, run a series of Git commands to initialize the repository, add files, commit, and push to GitHub.

Example: Executing the top set of commands

  1. Create the README.md file:
    echo "# test" >> README.md
  2. Initialize the Git repository:
    git init
  3. Add the README.md file:
    git add README.md
  4. Commit your changes:
    git commit -m "first commit"
  5. Set up your main branch:
    git branch -M main
  6. Add a remote to the GitHub repository:
    git remote add origin https://github.com/yourusername/yourrepository.git
  7. Push to GitHub:
    git push -u origin main

An error occurred in the command for commit #4; Git errors are often a good opportunity to learn how to use a command. Reading the error message carefully and following the instructions can solve many problems.

Author identity unknown

*** Please tell me who you are.

Run

git config –global user.email “you@example.com”
git config –global user.name “Your Name”

Run git config –global user.name “Your Name” to set your account’s default identity.
Omit –global to set the identity only in this repository.

fatal: unable to auto-detect email address (got ‘minok@n4060.(none)’)

One of the most common errors is that your username and email address are not registered in your Git configuration, and Git uses this information each time you commit to record who made the change.

How to set it up

To configure your Git username and email address, use the following command

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

Replace "Your Name" and "your_email@example.com" with the name and email address you want to use.

It is important to understand a few points about the name (user.name) and email address ( user.email ) used in the Git configuration.

Name (user.name)

  • This name is used to identify the commit. Technically, you can use any name you like, but it is generally a good idea to choose a name that will identify you to others collaborating on the project. A name that is meaningful to other developers, such as your real name or GitHub username, is recommended.
  • You can also use a “proper name,” but using your real name or an easily identifiable username will help promote transparency and cooperation on your project when tracking who did what in your commit history.

Email address (user.email)

  • The email address you set up in Git must be the email address you registered with GitHub. This ensures that GitHub correctly associates commits with your GitHub account.
  • If you use multiple email addresses with GitHub, you can use any email address, but if you want commits to be associated with your GitHub account, you must use the email address registered with your GitHub account.
  • GitHub also provides a setting to keep your email address private; you can use a “noreply” email address on GitHub to prevent your personal email address from appearing in public commit information.

Now you no longer get an error on commit #4 change. The last push to GitHub, #7, brings up a box, a login box to GitHub.

I was given the choice of a browser or a token, so I chose to launch my browser and log in. When you see “Authorize Git Credential Manager” in your browser, this means that GitHub credentials are now required for Git operations (for example, pushing to GitHub), Git Credential Manager (GCM) is a tool for securely storing and automatically using credentials (such as usernames, passwords, personal access tokens, etc.) for use in Git operations. This saves you the trouble of having to enter your credentials each time.

Authentication Flow with GCM

  1. Request credentials: GitHub credentials are required to perform Git operations (e.g., push to a remote repository).
  2. Launch your browser: Git Credential Manager automatically opens your browser and redirects you to the GitHub login page.
  3. Log in with GitHub: Follow the instructions to log in with your GitHub account. If you are using GCM for the first time, GitHub may ask you to grant access to the Git Credential Manager.
  4. Save and Use Credentials: Once you have successfully logged in, GCM will securely store your credentials and automatically use them for future Git operations.

Precautions and Remedies

  • Security: Although GCM stores your credentials securely, it is recommended that you keep up-to-date on security and enable two-factor authentication (2FA) for your GitHub account.
  • Personal Access Token (PAT): GitHub has discontinued password authentication in favor of more secure authentication methods such as PAT and OAuth; if you are using GCM, PAT is automatically used in this process.
  • Updating your credentials: If you need to update your credentials due to a GitHub password change, PAT expiration, etc., you will need to update your old credentials stored in GCM; see the GCM documentation or GitHub’s help section for detailed instructions.

Once the authentication process with GCM is complete, the secure exchange of credentials between Git and GitHub will be smooth and your Git operations will be more efficient. For actual operation in your browser, click the “Authorize git-ecosystem” button to display the login screen to GitHub.

By clicking the “Authorize git-ecosystem” button, you authorize the Git Credential Manager (or the associated Git authentication system) to access your account on GitHub. This allows you to access repositories, push code, create pull requests, and perform a variety of other operations on GitHub.

This process ensures smooth authentication between GitHub and your Git operations, and offers the following benefits

  • Secure management of credentials: Securely manage and store credentials such as usernames, passwords, and personal access tokens (PATs).
  • Auto-authentication: Once your credentials are set up, you no longer need to enter them every time you use GitHub, making your work more efficient.
  • Improved security: By managing GitHub access privileges properly, you can reduce the risk of unauthorized access.

After clicking the “Authorize git-ecosystem” button, log in with your GitHub account information and grant access as needed to complete the authorization process. This allows the Git Credential Manager to use your GitHub credentials to perform Git operations.

You have now completed the process of creating a repository on GitHub and pushing code from local to the repository; familiarity with Git and basic operations with GitHub is very important in software development. This experience was good practice for my future development activities.

When I checked the project in Explorer, I found a .git folder, which was treated as a hidden folder.

The .git folder is used to store version control information by Git and is automatically created in the project directory where Git is initialized. This folder contains all the metadata needed to version control the project, including repository configuration files, branch information, commit history, and remote repository information.

The .git folder is treated as a hidden folder because the contents of this folder are rarely manipulated directly during normal project work. It is also usually hidden from user view because accidental changes or deletions can affect the version control history of the project.

It is common to manage .git folders through the Git command line tool or an IDE (Integrated Development Environment) that supports Git. You will only need to manipulate the .git folder directly if you need to change certain settings or perform advanced version control operations.

To be safe, it is important that you fully understand what the operation entails when changing the contents of a .git folder. Incorrect operations can lead to repository corruption and data loss.

GitHub how the repository you have created is doing. Through this process, I was able to experience the basics of managing a repository on GitHub, working in a local environment, and pushing changes to a remote repository. This is an important skill not only for managing individual projects, but also for working collaboratively in teams.

The “familiar screen” I saw after creating a repository on the developer side was also evidence of my understanding of how to use Git and GitHub. This experience will help you in the future when working on more complex projects and collaborating with other developers.

Creating your own repository, cloning it, and starting work on it is a great opportunity to experience the software development process firsthand. Through this experience, you will gain a deep understanding of each stage of the development process: version control, code sharing, and feedback gathering.

There are many more features of project management, code sharing, and collaboration using GitHub. Managing branches, creating pull requests, tracking issues, and building a CI/CD pipeline with GitHub Actions are just a few of the topics worth exploring further.

Please share if you like it!
TOC