Cloud☁️02: Github (Recap)Forking🍴, Cloning🖨, Pushing➡️, and Pulling

Sheena Lynn Narciza
5 min readMar 4, 2023

--

Objectives:

  1. Fork the Level Up In Tech Repo Here: https://github.com/LevelUpInTech/LevelUpTeam
  2. Clone the forked repo to your ACG cloud server environment
  3. Using Vim, create a change to the linux.sh file that is in the repo directory
  4. Save the file and add to your local repo, then commit the file
  5. Push the file back to your own github repo
  6. Send a pull request to merge with Level Up In Tech production repo

Step 1 — Fork the Level Up In Tech Repo

  • Create or have access to a GitHub account. If you don’t have an account head over to https://github.com/ and create one.
sudo apt update
sudo apt install git
  • Select dropdown “Create a new fork” at the correct repository, you will be asked a few questions pertaining to the new fork you are creating. Renaming Owner and New Repository Name.
  • OOPS! I have already created a fork from this repo. Referring to my old post I would fork the repo from this link https://github.com/LevelUpInTech/LevelUpTeam and it should be in my repositories. Like shown below.

Step 2 — Clone the forked repo to your ACG cloud server environment

Now that we forked the repo into my repositories, we can clone it and make changes. Start by using the command and HTTPS link:

git clone < HTTPS link>

Get into LevelUpTeam Directory

cd /home/cloud_user/LevelUpTeam/
ls

The following files should be in the directory.

README.md  README.md.LUIT  badges  linux.sh

Step 3— Use Vim, create a change to the linux.sh file that is in the repo directory

vim linux.sh

Step 4 — Save the file and add to your local repo, then commit the file

We want to edit our linux.sh file in Vim. We will replace curl config command with:

COPY AND ADD TO VIM linux.sh

curl -4 icanhazip.com

NOTE:

curl — transfer a URL

option -4 : -4, — ipv4 This option tells curl to resolve names to IPv4 addresses only, and not for example try IPv6.See also — http1.1 and — http2. This option overrides -6, — ipv6.

Verify the modification

git status

We will now use git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.

git add linux.sh

Usince git commit -m command. The git commit command captures a snapshot of the project’s currently staged changes. Committed snapshots can be thought of as “safe” versions of a project — Git will never change them unless you explicitly ask it to.

git commit -m "Inserted curl -4 icanhazip.com in linux.sh to return my ip address"

Be sure you are at root directory. When entering these commands:

Verify who you are

Be sure to add your credentials from your Github account.

git init
git config user.name "Your_name"
git config user.email "example@example.com"

Encountered an error? See my previous post to resolve.

The git clone command is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The git clone command copies an existing Git repository.

git clone <HTTPS URL>
cloud_user@07f79512b92c:~$ ls
Desktop Downloads Music Public Videos
Documents LevelUpTeam Pictures Templates
git init
Reinitialized existing Git repository in /home/cloud_user/LevelUpTeam/.git/
git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean

The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged or not for your team.

Step 5 — Push the file back to your own github repo

The git push isused to upload local repository content to a remote repository. This will allow transfer commits from your local repository to a remote repo (the cloned repo you just created).

 git push -u origin main


OUTPUT
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 338 bytes | 338.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/Sheenanarciza/LevelUpTeam.git
ead4651..55ca087 main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

Step 6 — Send a pull request to merge with Level Up In Tech production repo

A pull request is also referred to as a merge request — let you tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.

  1. On GitHub, go to your main repositories.
  2. Click on Pull Request
  3. Click on New pull request

Once you made a pull you will see your commits (Commits can be thought of as snapshots or milestones along the timeline of a Git project).

--

--