GitHub Basics: A Beginner's Guide to Version Control and Collaboration

Development

20/12/2024

GitHub

I. What is GitHub?

Github is a hosting platform for git repositories. You can put your own git repos on Github and access them from anywhere and share them with people around the world. Beyond hosting repos, Github also provides additional collaboration features that are not native to git (but are super useful). Basically, Github helps people share and collaborate on repos.

II. Git vs. GitHub: What's the Difference?

  • Git: Git's version control software that runs locally on your machine. You don't need to register for an account. You don't need the internet to use it . You can use Git without ever touching github
  • Github: Github is a service that hosts Git repositories in the cloud and makes it easier to collaborate with other people. You do need to sign up to use Github. It's an online place to share work that is done using Git.
GitHub

III. Is GitHub the Only Option?

While GitHub is widely used, it's not the only platform available for hosting and collaborating on Git repositories. Alternatives like GitLab, Bitbucket, and Gerrit also provide similar features for version control and collaboration.

IV. Why should you use Github?

1. Collaboration: If you ever plan on working on a project with ai least on their person, Github will make your life easier! Whether you're building a hobby project with your friend or you-re collaborating with the entire world , Github is essential.

2. Exposure: Your Github profile showcases your own projects and contributions to other's projects. It can act as a sort of resume that many employers will consult in the hiring process . Additionally, you can gain some clout on the platform for creating or contributing to popular project

3. Open Source Projects: Today's Github is the home of open source projects on the internet . Projects ranging from React to Swift are hosted on Github. If you plan on contributing to open source projects, you'll need to get comfortable working with Github.

4. Stay Up to Date:Being active on Github is the best way to stay up to date with the projects and tools you rely on, Learn about upcoming changes and the decisions/debate behind them.

V. Key Considerations When Using GitHub

1. Cloning

So far, we've created our own git Repositories from scratch, but often we want to get a local copy of an existing repository instead . To do this , we can clone a remote repository hosted on Github or similar website . All we need is a URL that we can tell Git to clone for use.

2. Git clone

To clone a repo , simply run git clone <url>.

Git will retrieve all the files associated with the repository and will copy them to your local machine.

In addition, Git initializes a new repository on your machine, giving you access to the git history of the cloned project.

3. Permissions

Anyone can clone a repository from Github, provided the repository is public. You do not need to be an owner or collaborator to clone repo locally to the machine .You just need the URL from Github. Pushing up your own changes to the Github repo...that is another story entirely ! You need permission to do that ! 

4. SSH Key

You need to be authenticated on github to do certain operations, like pushing up code from your machine. Your terminal will prompt you every single time for your github email and passwords, unless..

You generate and configure an SSH key , Once configured, you can connect to Github without having to supply your username/password 

VI. Getting Your Code on GitHub

Option 1: Uploading an Existing Local Repository

If you already have a Git repository on your local machine, follow these steps to push it to GitHub:

  • Create a new repository on GitHub.
  • Connect your local repository by adding a remote.
  • Push your changes to GitHub.

Option 2: Starting from Scratch

If you don't have a local repository yet, follow these steps:

  • Create a new repository on GitHub.
  • Clone the repository to your local machine.
  • Make changes locally and push them back to GitHub.

VII. How To Change Code to GitHub

1. Pushing code

To push your changes to GitHub, follow this standard workflow:

  • Make changes locally.
  • Add and commit the changes.
  • Push the changes to GitHub.

2. Remote

Before we can push anything up to github, we need to tell git about our remote repository on github. We need to set up a “destination” to push up to.

In Git,We refer to these “destination” as remotes Each remote is simply a url where a hosted repost lives.

3. Viewing remotes

To view any existing remotes for your repository, we can run git remote or git remote -v (verbose,for more info). This just displays a list remote . If you haven't added any remotes yet, you won't see anything!

4. Adding a new remote

A remote is really two things : a URL and label . to add a new remote,we need to provide both to git.

5. Example adding a new remote: 

git remote add origin https://github.com/aaaa/aoma.git

Anytime I use the name "origin". I'm referring to this particular github repo url

  • Origin is a conventional git remote name,but it is not at all special. It's just a name for a URL. When we clone a Github repo, the default remote name setup for us is called origin. You can change it . Most people leave it.
  • Rename origin: They are a bit commonly used, but there are commands to rename add delete remotes if needed.  You can use two formula: git remote rename <old> <new> or git remote remove <name>
  • Pushing: Now that we have a remote set up, let's push some work up to Github! To do this , we need to use the git push command. We need to specify the remote we want to push to and the specific local branch we want to push to that remote. You can refer this formula: git push <label-remote> <branch-name>
  • Pushing in detail: While we often want to push a local branch up to a remote branch of the same name , we don't have to. You can refer this formula: git push origin <label-remote> <local-branch>:<remote-branch>
  • The -u option: The -u option allows us to set the upstream of the local master branch so that it tracks the master branch on the origin repo. This mean: git push <=> git push origin master 
GitHub

VIII. Conclusion

GitHub is an essential platform for modern software development, offering robust tools for version control, collaboration, and code sharing. Whether you're working on personal projects or contributing to open-source communities, understanding how to use GitHub efficiently can significantly improve your workflow. From cloning repositories and pushing code to managing remotes and setting up SSH keys, GitHub simplifies the development process and fosters collaboration. By mastering GitHub's features, you'll not only improve your coding skills but also gain exposure in the developer community, making it easier to collaborate with others and stay updated with the latest advancements in technology.

Featured posts

ss-white-paper-thumbnail

Agile Testing in Scrum: Methods and Best Practices

Agile Testing plays a pivotal role in Agile software development, ensuring that testing aligns with the dynamic, iterative, and collaborative nature of this methodology. This article explores Agile Testing within the context of Scrum, delving into its core principles, the Agile Testing Quadrants, and various methods such as Behavior-Driven Development (BDD), Acceptance Test-Driven Development (ATDD), and exploratory testing. By understanding these concepts, organizations can enhance the quality and efficiency of their software development processes while delivering products that align closely with customer needs.

Development

20/12/2024

ss-white-paper-thumbnail

Overview about Craft.js - library used for page builder

Building rich, customizable user interfaces is a challenge that many web applications face. Developers need solutions that provide flexibility, performance, and extensibility, especially for drag-and-drop editors, landing page builders, and WYSIWYG content creation. Enter Craft.js, a headless framework for building these complex user interfaces with React. In this guide, we will learn about the architecture of Craft.js, the workflows, custom components, state management, and extensibility.

Development

13/12/2024

Quyet

Related contents

ss-white-paper-thumbnail
Development
Overview about Craft.js - library used for page builder

Building rich, customizable user interfaces is a challenge that many web applications face. Developers need solutions that provide flexibility, performance, and extensibility, especially for drag-and-drop editors, landing page builders, and WYSIWYG content creation. Enter Craft.js, a headless framework for building these complex user interfaces with React. In this guide, we will learn about the architecture of Craft.js, the workflows, custom components, state management, and extensibility.

13/12/2024

Quyet

ss-white-paper-thumbnail
Development
Libuv in Node.js: Asynchronous I/O on Linux, macOS, and Windows

Node.js is a powerful platform for developing network applications, renowned for its ability to handle asynchronous I/O tasks. Libuv is the core library that provides the event loop and APIs for Node.js to manage I/O. This article will delve into how Libuv in Node.js operates, providing specific examples of I/O handling in Node.js across different operating systems while explaining how Libuv interacts with the operating system and how the event loop processes callbacks.

20/12/2024

ss-white-paper-thumbnail
Development
Data Fetching with Incremental Static Regeneration (ISR) in Next.js

Incremental Static Regeneration (ISR) in Next.js revolutionizes the way developers create or update static pages. By allowing static-generation on a per-page basis without rebuilding the entire site, ISR combines the benefits of static pages with the flexibility to scale seamlessly. In this guide, we’ll explore how ISR works, its implementation, and when to use it effectively.

17/12/2024