How to Install Git and Clone a GitHub Repository
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
GitHub is a website that allows collaboration between developers using the Git version control system. With Git and GitHub, programmers from across the world can share ideas and code in an organized and up-to-date process.
Install and Configure Git
The directions below are for Debian or Ubuntu. For installation on Mac, Windows, or other Linux distributions, find instructions in the Git Source Control Management guide. While that guide focuses on Git, this guide focuses more on Git with GitHub.
sudo apt-get update sudo apt-get install git -y
Configure the username, replace
git config --global user.name "First Last"
Configure the email, replace
git config --global user.email "[email protected]"
Now that Git has been installed, refer to the image below for help with using Git and GitHub together.
Clone a GitHub Test Repository
A repository, or repo, is a Git project. For tutorial purposes, there is a test repository setup on GitHub, which is listed below.
Go to the GitHub homepage. At the top, search for
test-repo-789. If you would like to contribute to Linode’s guides, search for
test-repo-789, it should be the first result, listed as
Copy the “HTTPS clone URL” link using the clipboard icon at the bottom right of the page’s side-bar, pictured below.
In the Linode terminal from the home directory, use the command
git clone, then paste the link from your clipboard, or copy the command and link from below:
git clone https://github.com/NwayNway/test-repo-789.git
Change directories to the new
To ensure that your master branch is up-to-date, use the pull command:
git pull https://github.com/NwayNway/test-repo-789.git master
Create a GitHub Account and Fork the Test Repo
To share new files or file revisions, you’ll need a GitHub account and a project fork. A fork is a copy of a repo held on your GitHub account.
Create a username on GitHub. At the “Welcome to GitHub” page, select the green, “Finish sign up” button at the bottom.
Select your username at the top right of the page, pictured below, which links to your profile.
test-repo-789, use the search bar at the top left of the page. Search for
After you select
NwayNway/test-repo-789, fork the repo using the “Fork” button on the top right of the page. The “Fork” button is under the username icon pictured in step 2 above.
You now have a copy of the repo on your GitHub account. Next, return to the terminal of the development Linode.
Push to the Forked Repo
Create files on the development Linode and push them to the forked repository on GitHub.
~/test-repo-789directory, create and checkout a new branch:
git checkout -b newbranch
Create a project directory:
Create sample files:
touch repoTest1.js repoTest2.htm project/prjtTest1.js project/prjtTest1.htm
Check the status of the Git project, with the
git status # On branch newbranch # Untracked files: # (use "git add <file>..." to include in what will be committed) # # project/ # repoTest1.js # repoTest2.htm nothing added to commit but untracked files present (use "git add" to track)
Add all the files in
~/test-repo-789to the Git staging area:
git add .
NoteTo add only one file, replace the period above with the full directory path and filename.
Check the status again with
git status, then commit the files to the Git project:
git commit -m "Test files for test-repo-789 fork"
Push the new files to the forked repo on your new GitHub account. Replace
SampleUser1234below with your own GitHub username, and replace the repo name with the appropriate repo name if different:
git push https://github.com/SampleUser1234/test-repo-789.git newbranch
NoteIf you’ve configure two-factor authorization (2FA) on this account, you will need to push over SSH. See GitHub’s guide on Generating SSH Keys.
Create a Pull Request Against the Original, Previously Cloned Repo
So far, Git was installed on a development Linode, a repo project was cloned to that Linode, a GitHub username was created, and a repo fork was copied to the GitHub user account. The final step is to ask the original repo project to accept the new revisions or sample files. This final process is called a pull request.
From the GitHub browser window, select your username from the top right of the page, pictured below.
At your GitHub profile, select the
test-repo-789in the center of the page, pictured below.
test-repo-789page, select “branches”.
Under “Your branches”, select “New pull request”.
Check that the branch filters are set correctly.
Select the “Create pull request” button.
Congratulations, you have used Git and GitHub for file sharing and version control. There are still many Git commands to learn, but you are off to a great start.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on