GitHub Basics: Creating Repository and Maintaining It
Published: 2024-05-27 08:59:31



![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716796035466_file.png)

 Table of content:
1. Definition
2. Requirements
3. Creating a new Repository
4.  Maintaining a Repository
    -       Fork the repository
    -       Clone the repository
    -       Create a branch
    -       Initializing a repository
    -       Adding files to the repository
    -       Make an Initial Commit
    -       Push changes to your repository 
    -       Pull requests
    -       Renaming a repository
    -       Transferring a repository
    -       Deleting a repository
    -       Restoring a deleted repository
5. Conclusion

 6. Useful resources


Definition

GitHub is a web-based tool for version control and collaboration. It provides developers with an easy-to-use interface for creating repositories (remote storage sites), tracking code changes over time (version control), and collaborating on projects with others.

Requirements
- GitHub Account
- Git Installed
- Text Editor or IDE
- Basic Command Line Skills

 

1. Creating a new repository

As a prerequisite you need a GitHub account to be able to create a repository.

Creating  a GitHub account


1. Navigate to https://github.com/.
2. Click Sign up.
3. Follow the prompts to create your personal account.

During sign up, you'll be asked to verify your email address. Without a verified email address, you won't be able to complete some basic GitHub tasks, such as creating a repository.
If you're having problems verifying your email address, there are some troubleshooting steps you can take. For more information, see "Verifying your email address."

Creating a new repository from the web UI
step 1-;
Once you have GitHub account,  In the upper-right corner of your page, click the + sign .

![](https://paper-attachments.dropboxusercontent.com/s_EE40DE016CCBB8ED67839E43DFBFF1CAF40900E02C4A5ACF09645F222AF3C1BB_1716379864701_github+repo1.png)


Step 2-:
On the drop down list, click on the  New repository option.

![](https://paper-attachments.dropboxusercontent.com/s_EE40DE016CCBB8ED67839E43DFBFF1CAF40900E02C4A5ACF09645F222AF3C1BB_1716380048718_github+repo2.png)


Step 3-;
Use the Owner drop-down menu to choose the account that will own the repository.

![](https://paper-attachments.dropboxusercontent.com/s_EE40DE016CCBB8ED67839E43DFBFF1CAF40900E02C4A5ACF09645F222AF3C1BB_1716380284935_github+repo3.png)


step 4-:
In the repository name field, enter a name for your repository and optionally provide a description. Select the desired repository visibility, then click the "Create repository" button at the bottom of the page.

For example-;

![](https://paper-attachments.dropboxusercontent.com/s_EE40DE016CCBB8ED67839E43DFBFF1CAF40900E02C4A5ACF09645F222AF3C1BB_1716380814631_githubrepo4.png)


Step 5-;
At this point, you have successfully created a new repository using the web UI.

![](https://paper-attachments.dropboxusercontent.com/s_EE40DE016CCBB8ED67839E43DFBFF1CAF40900E02C4A5ACF09645F222AF3C1BB_1716381027036_githubrepo5.png)



2. Maintaining a  Repository
1.  Fork the repository

Fork the repository by clicking the fork button on the top of the page. This will create an instance of that entire repository in your account.

![](https://www.freecodecamp.org/news/content/images/2020/01/fork-1.png)

2. Clone the repository

To work with the repository locally, clone it to your machine. Click on the "Code" button and copy the provided link.

![](https://www.freecodecamp.org/news/content/images/2020/01/clone1.png)


Open the terminal and run the following command. It will clone the repository locally.


    $ git clone [HTTPS ADDRESS]
    For example


    $ git clone hhtps://github.com/ThanoshanMV/articles-of-the-week.git
![](https://www.freecodecamp.org/news/content/images/2020/01/clone2.png)


Now we have set up a copy of the master branch from the main online project repository.

    $ cd [NAME OF REPOSITORY]
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716811359147_file.png)

3. Create a branch

It’s good practice to create a new branch when working with repositories, whether it’s a small project or contributing to a group's work.
Branch name should be short and it should reflect the work we’re doing.
Now create a branch using the `git checkout` command:

    $ git checkout -b [Branch Name]
![](https://www.freecodecamp.org/news/content/images/2020/01/branch1.png)



4. Initializing a repository: 

To initialize a new Git repository, open the terminal, navigate to the root directory of your project, and execute git init. This command initializes an empty Git 
repository in the specified directory and generates a .git sub-directory that contains versioning information.

![](https://paper-attachments.dropboxusercontent.com/s_BE26B31FA8ACA69A8DA80E5A511CCBE5BFC7C92A0BD8E15E54E328F07AA7FAD6_1716797776090_Screenshot+5.png)



 5. Adding files to the repository

Make essential changes to the project and save it.
Then execute `git status` , and you’ll see the changes.
Use the `git add` `.` command to add your project files to the repository after it has been initialized. For instance, you may use git add . to add all files in the repository. The files are ready to be included in the subsequent commit at this point.

![](https://paper-attachments.dropboxusercontent.com/s_CB69381EC21DE24566352E297717B7D6F7F46AFC9B02D51CD983123CFA753CF3_1716804715382_file.png)

6. Make an Initial Commit

Use the `git commit -m "Initial commit message"`     command to generate an initial commit once you have added the required files. Commits are a snapshot of the project at a particular moment in time and ought to have a detailed message detailing the modifications that were made.


 7.  Push changes to your repository 

  In order to push the changes to GitHub, we need to identify the remote’s name.

    $ git remote
![remote](https://www.freecodecamp.org/news/content/images/2020/01/remote.png)


For this repository the remote’s name is “origin”.
After identifying the remote’s name we can safely push those changes to GitHub.


1. On GitHub.com, navigate to the main page of the repository.
2. Above the list of files, click Code.
3. To clone your repository using the command line using HTTPS, under "Quick setup", copy link . To clone the repository using an SSH key, including a certificate issued by your organization's SSH certificate authority, click SSH, then copy link .
4. Open Terminal .
5. Change the current working directory to the location where you want the cloned directory.


![](https://paper-attachments.dropboxusercontent.com/s_CB69381EC21DE24566352E297717B7D6F7F46AFC9B02D51CD983123CFA753CF3_1716805735661_file.png)



    git push origin [Branch Name]

 

8. Pull requests

To create a pull request that is ready for review, click Create Pull Request. To create a draft pull request, use the drop-down and select Create Draft Pull Request, then click Draft Pull Request.

![](https://www.freecodecamp.org/news/content/images/2020/01/compare.png)




9. Renaming a repository
- On GitHub.com, navigate to the main page of the repository.
- Under your repository name, click  Settings. If you cannot see the "Settings" tab, select the  drop-down menu, then click Settings.
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716454189564_Screenshot+19.png)

    - In the Repository Name field, type the new name of your repository.
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716454401165_Screenshot+20.png)

    Click Rename.
- Warning: If you create a new repository under your account in the future, do not reuse the original name of the renamed repository. If you do, redirects to the renamed repository will no longer work.
10. Transferring a repository
- When you transfer a repository that you own to another personal account, the new owner will receive a confirmation email. The confirmation email includes instructions for accepting the transfer. If the new owner doesn't accept the transfer within one day, the invitation will expire.
    1. On GitHub.com, navigate to the main page of the repository.
    2. Under your repository name, click  Settings. If you cannot see the "Settings" tab, select the  drop down menu, then click Settings.
    3. 
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716454189564_Screenshot+19.png)

    1. At the bottom of the page, in the "Danger Zone" section, click Transfer.
    
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716454289159_Screenshot+21.png)

1. Read the information about transferring a repository, then under "New owner", choose how to specify the new owner.
    
            - To choose one of your organizations, select “Select one of my organizations.”
            
                - Select the drop-down menu and click an organization.
                - Optionally, in the "Repository name" field, type a new name for the repository.
                - Note: You must be an owner of the target organization to rename the repository.
                
            - To specify an organization or username, select Specify an organization or username, then type the organization name or the new owner's username.
            
2. Read the warnings about potential loss of features depending on the new owner's GitHub subscription.
3. Following “Type Repository Name to confirm”,  type the name of the repository you'd like to transfer, then click I understand, transfer this repository.
11. Deleting a repository
- On GitHub.com, navigate to the main page of the repository.
- Under your repository name, click  Settings. If you cannot see the "Settings" tab, select the  drop-down menu, then click Settings.
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716454189564_Screenshot+19.png)

    - On the "General" settings page (which is selected by default), scroll down to the "Danger Zone" section and click Delete this repository.
    - Click I want to delete this repository.
    - Read the warnings and click I have read and understand these effects.
    - To verify that you're deleting the correct repository, in the text box, type the name of the repository you want to delete.
    - Click Delete this repository.
12. Restoring a deleted repository

Some deleted repositories can be restored within 90 days of deletion. 

1. In the upper-right corner of any page, click your profile photo, then click Settings.
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716453361266_Screenshot+18.png)

1. In the "Code planning, and automation" section of the sidebar, click  Repositories.
2. Under "Repositories", click Deleted repositories.
    Next to the repository you want to restore, click Restore.
    Read the warning, then click I understand, restore this repository.
    
![](https://paper-attachments.dropboxusercontent.com/s_38FC6ABDD3D8682B66D8DFE51B556581B97E7925E3BA8C4888A806AB24F56E1C_1716453151007_Screenshot+17.png)

13.  Conclusion

Repositories on GitHub are an effective tool for organizing and working together on software projects. Developers may assure project transparency and version control, promote teamwork, and expedite workflows by adhering to best practices when creating, organizing, and managing repositories. Leveraging GitHub repository capabilities can greatly improve code quality and efficiency, whether working on a team project or a personal one.

14. Useful Resources

Official GitHub Documentation

- GitHub Docs: https://docs.github.com/en
- Creating a repository: https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository
- Managing repositories: https://docs.github.com/en/repositories

Git and GitHub Learning Resources

- Git Handbook: https://guides.github.com/introduction/git-handbook/
- GitHub Learning Lab: https://lab.github.com/
- Git & GitHub Crash Course for Beginners (Video): https://www.youtube.com/watch?v=RGOj5yH7evk

Tutorials and Guides

- GitHub Guides: https://guides.github.com/
- GitHub Skills: https://skills.github.com/
- FreeCodeCamp GitHub Tutorial: https://www.freecodecamp.org/news/git-and-github-for-beginners/

Books

- "Pro Git" by Scott Chacon and Ben Straub (free online book): https://git-scm.com/book/en/v2
- "GitHub For Dummies" by Sarah Guthals and Phil Haack

Community and Forums

- GitHub Community: https://github.community/
- Stack Overflow (GitHub tag): https://stackoverflow.com/questions/tagged/github