0% found this document useful (0 votes)
26 views27 pages

Practical Guide To Using Git With Github

This document provides a practical guide for using Git and GitHub. It explains what version control is and why Git is a good choice. It details how to create a repository on GitHub and how to install and configure Git on different operating systems. Finally, it offers instructions on how to link a local repository to a remote one on GitHub.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views27 pages

Practical Guide To Using Git With Github

This document provides a practical guide for using Git and GitHub. It explains what version control is and why Git is a good choice. It details how to create a repository on GitHub and how to install and configure Git on different operating systems. Finally, it offers instructions on how to link a local repository to a remote one on GitHub.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

FULL STACK PROGRAMMING COURSE

TUTORIAL: GUIDE
USAGE PRACTICE
GIT WITH GITHUB
GIT GUIDE WITH GITHUB
What is version control?
The version control systems they are programs that aim to control the
changes in the development of any type of software, allowing to know the current state
of a project, the changes that have been made to any of its parts, the people
who intervened in them, etc. The version control software keeps track of
all modifications in the code in a special type of database. If a mistake is made
an error, developers can go back in time and compare previous versions
the code to help resolve the error while minimizing disruptions to
all team members.

Developers working in teams are continuously writing new


source code and changing the one that already exists. The code of a project, an application or a
software components are usually organized in a folder structure or 'tree
of files." A developer from the team could be working on a new feature.
while another developer fixes an unrelated bug by changing code. Each
Developer could make their changes in various parts of the file tree.

Version control helps teams resolve these types of issues by performing


monitoring of all individual changes of each collaborator and helping to prevent
that concurrent work comes into conflict.

Ultimately, having control over the changes in the codes of our application is a
crucial variable for the success of our development. Git it is a version control system
open source, designed to handle large and small projects quickly and
efficiency. The aim of this tutorial is to address the basic use of Git by providing
Useful practical examples to start managing remote repositories with platforms
like Bitbucket or GitHub .

VERSION CONTROL WITH GIT


Git is the best option for most current software teams. Although each
the team is different and should conduct its own analysis, here we gather the main ones
reasons why Git's version control stands out compared to other alternatives:

GIT IS AN EXCELLENT TOOL


Git has the functionality, performance, security, and flexibility that most of the
teams and individual developers need. In direct comparisons with great
Besides the other alternatives, Git is very advantageous for many teams.

GIT IS A HIGH-QUALITY OPEN SOURCE PROJECT


Git is a well-supported open source project with over a decade of
highly reliable management. The people responsible for maintaining the project have demonstrated a
balanced criteria and a mature approach to meet the long-term needs of
its users with periodic publications that improve usability and functionality.

1
The quality of open source software is easy to analyze and countless
companies depend greatly on that quality.

Git has a large user base and strong support from the community.
documentation is exceptional and by no means scarce, as it includes books, tutorials, and websites
specialized websites, as well as podcasts and video tutorials.

The fact that it is open source reduces the cost for amateur developers,
since they can use Git without having to pay any fee. As for
Open source projects, there is no doubt that Git is the successor to the previous ones.
generations of the successful open source version control systems, SVN and
CVS.

GITHUB
GitHub is a platform created to host the code of any applications.
developer. The platform is created for developers to upload the code of
its applications and tools, and as a user, you can not only download it
application, but also to enter their profile to read about it or collaborate in its development.

A version control system is one with which developers can


manage your project , organizing the code of each of the new versions that
they take them out of their applications to avoid confusion. Thus, by having copies of each of the
versions of your application, previous states will not be lost when updating.

Git, being a control system, will be the tool that will allow us to compare the
code of a file restore versions
to see the differences between the versions
old if something goes wrong, and merge changes from different versions.

Thus, Github is a portal for managing projects using the Git system.

HOW ARE WE GOING TO ACHIEVE THAT?

Github allows developers to host projects by creating repositories in a way


free. A repository is like a folder for your project. The repository of your project
contains all the files of your repository and stores the review history of each
file. You can also discuss and manage your project work within the
repository.

2
CREATE A REPOSITORY IN GITHUB
To upload your project to GitHub, you will need to create a repository to host it. In order to
to create a repository we will need to create an account on GitHub.

1) In the upper right corner of any page, use the dropdown menu and +
select New Repository

2) Write a short and easy-to-remember name for your repository. For example: 'hello-'
world

3) You can also add a description of your repository. For example, 'My first
repository on GitHub.

4) Choose the visibility of the repository. You can restrict who has access to a repository.
choosing the visibility of a repository: public or private. Public means that
anyone can see that repository and private means that only people
Authorized people can see it. Just because it is public does not mean that people can upload things.
to our repository, the only thing it allows is for the files to be viewed.

3
We can create the repository with a ReadMe

6) Click on Create repository.

GIT INSTALLATION
Once we have created a repository on GitHub we will need to install Git

GIT INSTALLER FOR MAC


Apple's Git model comes pre-installed on macOS. Open your terminal or script editor.
the shell of your choice and enter git --version to check what version of Git is on your
machine. If it is not yet on your machine, run git --version it will ask you to install Git.

While this Git build is fine for some users, you may want to
install the most updated version. You can do it in many different ways; we have
I have compiled some of the easiest options below.

One way to install Git on a Mac is through the standalone installer:

A. Download the latest Git installer for Mac from here:

The provided text is a URL and does not require translation.

4
B. Follow the instructions to install Git.

Open a terminal and type the following text to check that the installation has been
successfully completed:

git_version

$ git --version
gitversion2.9.2

Another way is to install Git using HomeBrew:

Homebrew installs a list of useful packages that do not come pre-installed on Mac.

A. Paste the following command in your terminal to install Homebrew:

/bin/bash -c "$(curl -fsSL


The provided input is a URL and cannot be translated.
.sh)

B. The terminal will ask you to enter a password. Enter the password you use for
log in to your Mac and continue with the installation process.

C. Once finished, enter brew install git in the terminal and wait for it to download.
Check that Git is installed by running git --version .

GIT INSTALLER FOR LINUX


Debian / Ubuntu (apt-get)

The Git packages are available via APT:

1. From your core, install Git using apt-get:

$ sudo apt-get update


$ sudo apt-get install git

2. Enter the following text to verify that the installation has been completed
correctly

git_version

$ git--version
gitversion2.9.2

GIT INSTALLER FOR WINDOWS


Download theGit installer for Windowsmore recent.
2. When you have successfully launched the installer, you will see the assistant screen.
of Git installation.
3. Select the Next and Finish options to complete the installation. The
default options are the most logical in most cases.

5
4. Open the command prompt (or Git Bash if you selected not to use it during installation
Git from the Windows command prompt.
5. Enter the following text to verify that the installation has been completed
correctly

git_version

$ git --version
gitversion2.9.2

INITIAL CONFIGURATION
Open your Git terminal to start executing commands, for example, it will open
the program Git bash in Windows to access the command line of this program.

Once logged in, use the following command to set the git username:

git config --global user.name "Jhoel Perez"

Remember to replace the text in quotes with your real name. Now indicate the email
user's email for git:

git config --global user.email "[email protected]"

Replacing the text in quotes with their email address. This setting
initial should be enough to get started. To check other values of your
current configuration execute:

git config --list

The new configured values will be shown at the end, along with other configuration values.
predetermined:

...
auto
auto
...
Juan Perez
[email protected]

WAYS TO START WORKING WITH GIT


To work with Git and GitHub, we have two ways to work:

1) Work locally, in a repository that I create on my machine and link it to a


repository created on GitHub

2) Clone a GitHub repository (or another repository hosting) to bring it locally.


the complete repository and start working on that project.

6
Let's choose option 1) for the moment, which will allow us to start from scratch and with the
we will be able to better appreciate what the basic operations with Git are. In this sense,
any operation you perform with Git must start with working locally,
so you need to start by creating the repository on your own machine. Even if your
The objectives are simply to upload that repository to Github so that other people can access it.
accessing through the remote hosting of repositories, you have to start working on
local.

STARTING A NEW REPOSITORY: GIT INIT


First, we should create an empty folder to initialize our repository, once that
we have it created we must tell the terminal to stop in that folder, this way all the
Git commands affect that folder.

In Windows, we can right-click on the folder and click on Git Bash Here , that gives us

It will open the Git Bash terminal in the folder to work with Git.

On a Mac we can do the same, right click on the folder and select the option New
Terminal in the folder .

Once stopped in our folder. To create a new repository, use the command git
init. git init is a command that is used only once during the initial setup of a
new repository. When you run this command, a new subdirectory will be created .git in your
current working directory. A new main branch will also be created.

$ git init

SAVE CHANGES IN THE REPOSITORY: GIT ADD AND GIT COMMIT


Now that you have started or cloned a repository, you can make commits to the version of
file. We are going to go to our folder and we are going to create a txt file with our name
Written, once we have it created we will execute the following commands.

Git Status

The git status command gives us all the necessary information about the current branch.

git status

We can find information such as:

• If the current branch is up to date

• If there is something to confirm, send or receive (pull).

• If there are files in preparation (staged), not prepared (unstaged) or that are not there
receiving tracking (untracked)

• If there are files created, modified, or deleted

7
Note: We will see the concept of branches later.

We perform a git status in our repository to see the current state.

Git Add

When we create, modify, or delete a file, these changes happen locally and
They will not be included in the next commit (unless we change the configuration).

We need to use the git add command to include the changes from the file or files in your
next commit.

Add a single file:

git add <file>

Add everything at once:

git add .

If you check the screenshot of the git status, you will see that there are filenames in red -
this means that the unprepared files. These files will not be included in your
commits until you add them.

We make a git add . to add our txt file. Once we do git add
we do another git status, now we will see that the files that were in red are in green
this means that we have already added them to make our commit.

Git Commit

This is perhaps the most used command in Git. Once you reach a certain point in the
development, we want to save our changes (maybe after a task or matter
specific) or upload a file / project.

Git commit is like setting a checkpoint in the development process to which


You can come back later if necessary. It's like a save point in a video game.

We also need to write a short message to explain what we have developed or


modified in the source code.

git commit -m "commit message"

8
We make a commit to save our txt and we put a message that explains what
we have done.

LINK OUR REPOSITORY WITH GITHUB


First, we should create a repository, without the readME file.

Once we have the file added and saved locally, we have to


link this local repository to a remote repository on GitHub. For this, we will use
the command git remote add.

This command will take the alias of our repository and the URL of our repository in
GitHub will connect it with our local repository.

git remote add <name> <url>

The alias we are going to use for Github is origin and to obtain the URL of our repository,
we can find it at the beginning of our repository:

We search for the URL of our GitHub repository and we do it in our terminal.

So we will putgit remote add origin <url>

COLLABORATION BETWEEN REPOSITORIES: GIT PUSH


After confirming your changes and linking the local Git repository with
the remote GitHub repository, the next step you want to take is to send your changes or
files to the remote server. git push send your commits to the remote repository.

git push <remote-name> <your-branch-name>

Anyway, if your branch was created recently, you may need to load and
push your branch with the following command:

git push origin <name-of-your-branch>

Let's remember that we use the alias origin for the remote repository.

When we create a repository on GitHub, it creates a default branch called main.


can we change in the settings so that the branch created by default is called
master.

So now we will run the following command in our terminal:

git push origin main

git push origin master

Once we have done this, if we refresh our repository we will see our
txt file in our GitHub repository.

9
This process will be repeated, removing the linking and the initialization of the repository, each
Once we make a change within our repository. This can be
modify an existing file or add more files to the local folder.

BRANCHES IN GIT

We often need to work with more than one person on the same project. But,
What happens if more than one developer makes changes to the same file? Or worse,
What happens if both change the same line of code?
To avoid this type of problems and permanently collide code, git provides the
branching tool (branch). This way, you can create your own branch of the
project and make all the changes you need, and at the end of the process create a pull
request to merge (combine your changes) with the main branch, main or master.

GIT CHECKOUT and GIT BRANCH


The command git branch it is the one we will mainly use to work with the creation of
branches, branch deletion and so on. However, it is not the only command for the operation
what we will see in this article, as there are other useful and necessary Git subcommands
to work with branches, such as checkout to create and move between branches

You can start your first practice to work with branches. We will do something as simple
how to run the command 'git branch' as it is. This will give us the list of branches that
let's have in a project. But it should be noted that the branches of a local repository
they can be different from the branches of a remote repository. For example, when you clone a
GitHub repository you are generally cloning only the master branch and not all
the branches that have been created over time. Another example is when you create a
branch in your local repository. In this case, you will simply have the branch in your project.
local and it will not be uploaded to the remote repository until you specify it.

THE MASTER BRANCH OR MAIN

When we initialize a project with Git, we are automatically on a branch.


referred to as 'master'.

You can see the branch you are on at any moment with the command:

git branch

This branch is the main one of your project and from which you can create new branches.
when you need it.

If you have made any commit in your repository, you will notice that after running the command
git branch informs us that the name of the branch is 'master'.

Let's remember that in GitHub this branch can be called Main, we can always change it.
branch name to Master with the GitHub configurations.

CREATE A NEW BRANCH


The procedure to create a new branch is very simple. Using the checkout command
followed by the name of the branch we want to create. The dash b creates the branch
and switch to that new branch.

10
git checkout -b your_branch_name

If we look closely, we not only created a new local branch, but now we stand on the
new branch that we created.

We can obtain a more detailed description of the branches with this other command:

git show-branch

This shows us all the branches of the project with their completed commits. The output would be
like that in the following image.

As we can see, the new branch already has the first commit we made in the branch.
master because, as we explained above, we are cloning the master branch.

SWITCHING FROM ONE BRANCH TO ANOTHER

To switch between branches we use the command git checkout followed by the branch name
what we want to be the active.

git checkout your_branch_name

This would look like this:

This simple operation has a lot of power, because it will automatically change all of us.
the files of our project, those from all the folders, so that they have the content in
those who are in the corresponding branch.

At the moment in our example, both branches had exactly the same content.
but now we could start making changes to the ramaGit project and its
corresponding commits and then the files will have different codes, so that
you can see that when switching from one branch to another there are changes in the files.

As we explained before, each time you want to push a change to your branch, position yourself in
she executes the commands:

git add filename (dot (.) instead of the name if you want)
add all changed)

11
git commit -m "Message of the changes"

We are not going to make a push yet because we will explain that later, since
this will make our branch appear in the remote repository.

Having made a commit in our new branch, you will notice that when doing the show-
branches will show you new data:

If you are dedicated to editing your files, creating new files, and so on in the different branches
Then you will be able to observe that as you move from one to another, the project changes.
automatically in your editor, showing the current status in each of the branches where
you're getting situated. It's something fun, and if you're new to Git you'll see that it's a magic that works out.
quite surprising.

As you can see, the project can have several states at a given moment and you will be able to
move from one to another with total freedom and without having to change folders or anything like that.

PUSH A BRANCH TO THE REMOTE REPOSITORY


As we mentioned earlier, no matter how much you perform the described operation to create
branches on your computer, and you can see them in your local repository with git branch, the branches do not
will be published on Github or any other remote repository hosting. For this to
You have to specifically perform the action of pushing a certain branch.

The operation of publishing a branch remotely is done using the push command, indicating
the name of the branch you want to push. For example like this:

git push origin your_branch_name

This is how we are doing a push, pushing to origin (which is the name usually given)
to the remote repository).

12
If you don't want to always use origin and the name of your branch in your pushes, you need to add it.
the previous push, before
-u the word origin. This will allow you to use git push only
and always go to that branch.

It is important to make sure that we do it on our own branch and not on master, since
We could send changes to the master branch thinking they were going to ours.

This would be like this:

git push -u origin your_branch_name

Once this is done, we could stop in our branch and simply write:

git push

Once we do to see the branches, we will first go to branches:

And there we will be able to see the two branches

You can upload as many commits as you see fit to your branch before merging to master.
It is always better to have small and frequent changes than few and large ones.

MERGE BRANCHES
As you create branches and change the state of folders or files, your project
It will start to diverge from one branch to another. The moment will come when you will be interested in merging.
branches to be able to incorporate the work done into the master branch.

13
The melting process is known as merge and it can be very simple or more
complex if there are changes that Git cannot process automatically. Git
to process the merges, use a common ancestor and check the changes that have been made
introduced to the project since then, combining the code from both branches.

To make a merge, we place ourselves on a branch, in this case the 'master', and we say with
which other branch should the code be merged into.

The following command, executed from the 'master' branch, allows merging it with the branch
ramaGit

git merge gitBranch

Unmerge needs a message, just like happens with commits, so when doing that
the command will open 'Vim' (or any other console editor you have configured) to
You can exit Vim by pressing
the ESC key and then typing :q and pressing enter to accept that command. This
the operation to indicate the message can be summarized with the command:

git merge ramaGit -m "This is a merge with a message"

Then we can verify that our master branch has all the new code from the
ramaGit and we will be able to make new commits in master to continue the development of our
project already with the main branch, if it is our wish.

PULL REQUEST
Previously, we had merged our branches through the command merge , but GitHub
allows us to merge our branches and also see the changes that are between one branch and
another, thanks to the Pull Request

We are going to stop again at a stage where we have not merged the branches. Until
at that point we had managed to separate our changes from the rest of the team,
but the time to publish our changes was approaching and the need to know and/or
validate how different our version is and to see that everything is fine to merge those changes.
This is where the pull request tool comes to the rescue.

To create a pull request we must go to the branches section, find our branch and
click on the button New pull request .

14
Before making our pull request, we can see how many commits (changes) there are.
they separate to another branch from master. If we look, we get two zeros, but if master were
one commit ahead of some branch would come out as a one in the zero on the left and so on
increase the number according to the number of commits ahead of master. Now, if
the number is to the right, it would mean that the other branch is x commits ahead of master.

Here we can see an example with Git branch:

As we can see, branchGit is one commit ahead of master, so if


we merge the branches, it would be just one commit that would be applied to master.

15
It will show us something similar to the following.

References:

1. On the left, select the target branch that we want to merge into.
changes, our current branch to the right. We can always create a pull request
and change the branches we want to merge.
2. In this section we can put an informative title about what our
changes and a description as additional documentation. Details of the changes
proposed, test plan, etc.
3. This section shows us a summary of the commits and modified files.
4. In the last section, it shows us the details of the modified files. To
to visualize the changes we can switch between the 'Unified' and 'Split' view modes

Until this moment we have not created anything, we are just looking at a previous summary.
to continue we click on the 'Create pull request' button. Next, we will see the pull
request created in the following way.

On the other hand, we can use the 'Files changed' tab to do code review.

16
If we detect any line of code that requires changes, you can click on it and
add a comment so that the author of the pull request can modify it. It is not necessary
create a new pull request to update the changes, simply by making a
A commit on the branch is enough, GitHub takes the changes and updates the pull request.
automatically.

If everything is fine and there are no conflicts, we can merge our branch into master by clicking
on the “Merge pull request” button and in this way, the branch cycle ends.

Finally, we have the option to approve the changes so that the author of the pull request
merge on your change.

Once we merge the changes in our branches, it will say that the branch has been
merged.

17
DELETE A BRANCH
Sometimes it may be necessary to delete a branch from the repository, for example because
we may have made a mistake in the name when creating it. Here the operation may be different,
depending on whether we have already pushed that branch to remote or if it is still only local.

DELETION OF THE BRANCH LOCALLY


We achieve this with the git branch command, only now we use the option
-d to indicate that we want to delete that branch.

git branch -d branch_to_delete

However, this action may not work for us because we may have made changes that
are not saved in the remote repository, or have not been merged with other branches. In
the case that we want to force the deletion of the branch, to delete it regardless of
if the push or merge has been done, you will need to use the option -D .

git branch -D branch_to_delete

You must pay special attention to this option "-D", since deleting this way can
there are changes that can no longer be recovered. As you can see, it is quite easy to
confuse with "-d", a safer option, as it does not allow deletion of branches in situations
where code can be lost.

DELETE A BRANCH REMOTELY


If the branch we want to delete is in the remote repository, the process is a bit
different. We have to make a push, indicating the --delete option, followed by the branch that
It is desired to delete.

git push origin --delete branch_to_delete

DOWNLOAD A REMOTE BRANCH


Sometimes it happens that branches are created remotely, for example when they have been created by
other users and uploads to repository hosting, such as GitHub or similar, and we need
access them locally to verify the changes or continue the work. Initially those
remote branches created by other users are not available to us locally,
but we can download them.

The process to obtain a branch from the remote repository is quite simple. First, we would use
the git checkout command to create the missing branch locally and we use -b to
to stand on it.

git checkout -b your_branch_name

18
Once we have done that, we can get everything that is in the branch with the command
pull, putting the alias of the remote repository and the name of the branch:

git pull origin branch_to_download

GIT PULL
We just saw that we use the git pull command to download the branch, so let's go to
explain a little more about this command.

Git pull It is a Git command used to update the local version of a repository.
from another remote.

It is one of the four commands that requests network interaction by Git. By default, git
pull does two things.

Update the current working branch (the branch that has been switched to currently)

2. Update the remote branch references for all other branches.

git pull retrieves (git fetch) the new commits and merges (git merge) them into your branch
local.

USING GIT PULL


Use git pull to update a local repository from the corresponding remote repository.
Example: While you are working locally on master, run git pull to update the copy
master location and update the other remote tracking branches.

However, there are some things to keep in mind for that example to be
true

The local repository has a linked remote repository.

• Confirm this by running git remote -v

• If there are multiple remotes, git pull might not be sufficient information. It is possible
you should enter git pull origin or git pull upstream.

CLONE A REPOSITORY
Now we are going to talk about the cloning operation of a repository, the process you have
What to do when you want to bring the code of a project that is published on GitHub and
Do you want to restore it on your computer, so you can use it locally, modify it, etc.

This step is quite basic and very easy to do, but it is essential because you will need it.
do many times in your work as a developer. We will also try
complement it with some useful information, so that you can learn useful things and
a little more advanced.

DOWNLOAD VS CLONE
At the beginning of using a site like GitHub, if we have no idea how to use Git, we can also
obtain the code from a repository by downloading a simple Zip. You can get this option
through the button in the following image.

19
However, downloading a repository like this, although very simple, does not allow you some of the
interesting utilities of cloning it, such as:

• Does not create a local Git repository with the changes that the remote repository has.
held over time. That is to say, you download the code, but nothing more.

• You will not be able to push changes to the remote repository once you have made them.
locally.

In summary, you will not be able to generally use the advantages of Git in the downloaded code. So
it is better to clone, as learning to perform this step is also very simple.

CLONE THE GIT REPOSITORY


So let's see how you should clone the repository, so you can benefit from it.
Git with the downloaded code. The process is as follows.

First, you will copy the URL of the remote repository that you want to clone (see the 'Copy to' icon)
clipboard in the following image.

Then you will open a terminal window to navigate to your project folder that
you want to clone. I would recommend you to create a folder directly with the name of the
project that you are cloning, or any other name that seems better to you for this
repository. You locate yourself within that folder and from it we launch the command to do
the clone, which would be something like this:

git clonehttps://github.com/EggEducacion/MyFirstRepository.git.

20
The last point, after the URL copied from git, indicates that the clone will be placed in
the folder where you are located, in your terminal window. The output of that command would be
more or less like you have in the following image:

In this way, we already have the remote repository to work locally and we will be able to
make the changes we want and upload the changes with the commands we explained
previously.

INVITE COLLABORATORS TO A PERSONAL REPOSITORY


We saw how to clone a repository to be able to use its code and if we wanted to do
changes and upload those changes. All GitHub users can see and clone your
repository, as long as it is a public repository. But not everyone who
If they clone your repository, they can upload their changes, since GitHub understands that repositories
they are our property and we are the only ones who can modify it.

Now, how do we do when we want several people to work on the same


repository and we want GitHub to allow them to upload those changes. For that dilemma, GitHub allows us
Let me invite collaborators to our project. This will be done as follows:

Request the username of the person you are inviting as a collaborator.


2. On GitHub, visit the main page of the repository.
3. Under your repository name, click on Configuration .

4. In the left sidebar, click on Manage access .

21
5. Click on Invite a collaborator.

In the search field, start typing the name of the person you want.
invite, then click on a name from the list of results.

7. Click on Add to repositoryName .

8. The user will receive an email inviting them to the repository. Once that
accept the invitation, you will have collaborator access to your repository. The invitations
licenses will expire after 7 days. This will reset any licenses without
complain.

22
LEARNING QUESTIONS
What is Git?

a) A platform of remote repositories


b) A name for GitHub
c) A programming language
d) A version control system

What is GitHub?

a) A platform of remote repositories


b) A name for GitHub
c) A programming language
d) A version control system

What command do we use to start a repository locally?

a) Git clone
b) Git commit
c) Git init
d) Git status

4) What command do we use to obtain information about our branch?

a) Git help
b) Git add
c) Git info
d) Git status

5) What command do we use to include the changes in the local repository?

a) Git add
b) Git clone
c) Git status
d) Git init

6) What command do we use to save our changes in the local repository?

a) Git clone
b) Git save
c) Git commit
d) Git add

What command do we use to send our changes to the remote repository?

a) Git send
b) Git push
c) Git pull
d) Git remote

23
What command do we use to create a branch?

a) Git branch
b) Git checkout -b
c) Git clone
d) Git init

What command do we use to merge the changes from two branches?

a) Git merge
b) Git join
c) Git pull
d) Git push

10) To merge our changes from two branches in the remote repository we will use:

a) Pull Request
b) Git Merge remote
c) Pull Merge
d) None of the above

11) What command do we use to clone a GitHub repository?

a) Git pull
b) Git clone
c) Git download
d) Git remote

24
LEARNING EXERCISES
Now it's time to put into practice everything seen in the guide.

WATCH VIDEOS:

A. Fundamentals Basics of Git


B. Initialization Local Repository
C. Send Information between Repositories
D. Moverse between Different Commits

1. We are going to create a folder with a txt file, inside put the text we want, this
the folder along with the txt must start as a local repository. Furthermore
We should upload this file to a remote repository.

2. Now we need to modify the txt and upload those changes to the remote repository.

WATCH VIDEOS:

A. Creation of a New Branch


B. Merge between branches
C. Clone a Repository
D. Review of Commands

3. For the following exercise, you will have to work in a team with your classmates.
table.

a) The facilitator of each team must create a public repository with the name
practice_github selecting the option Initialize this repository with a README.
b) Once the repository is created, the facilitator must invite the members of their group.
to the same. Click on the Invite a collaborator button and search for the members of your
table by username or email.
c) Each member must accept the invitation to the repository. Check the invitation.
email and click on View Invitation.
d) Clone the repository. Each team member must clone the repository with the
ReadMe file. After accepting the invitation, GitHub redirects you to the repository.
e) Each member of the table, including the facilitator, must create their own branch to
work on the ReadMe file
f) Now each member of the table must include their name in the ReadMe file.
local way and upload it to your branch.

g) When all members of the table have added their name to the ReadMe file,
one by one, merge all your changes into the master branch. In the end, they
There should be a ReadMe file with all their names.

4. Now you are going to continue working as a table. Your task now is that each member
From the table, including the facilitator, must create their branch and create one of the following
Cat, Dog, Horse, Rabbit, Bird, and Duck. Each one will assign the attributes
that you desire.

25
The facilitator will have to create the repository and upload an empty Java project for
that the members of the board can clone and create their class. Once each member
They have created their class in their respective branch, they must merge all the classes in the branch.
master, so that the final project is completed.

26

You might also like