Activity #3 Github Fundamentals

NICOLAS, MONETTE P. BSIT 4RTH YEAR

Here’s a guide on how you can create and upload a Git Fundamentals tutorial to Hashnode and Medium, including essential Git commands.

1 . Git Commit

Command: git commit -m "Your commit message"

Description: This command saves the staged changes to your local repository with a message describing the changes.

Explanation of the Command Git Commit Command

Command: git commit -m "your message"

Purpose: The git commit command is used to save changes in the local repository. The -m flag is used to add a commit message, describing what changes were made.

Warning: The output is showing permission warnings for certain directories. These warnings indicate that Git could not access those directories due to permission restrictions. It’s common when running Git from certain directories in Windows.

Untracked Files:

After the initial commit, Git lists untracked files (files that haven't been added to Git yet). You would use git add to track these files before committing. The list shows files such as .gitignore, Documents/, Downloads/, etc., which are not tracked by Git yet.

2. GIT PULL

Command: git pull

Description: Fetches and merges changes from the remote repository to your local repository.

Explanation of the Command Git Pull Command

Purpose: The git pull command fetches and merges changes from a remote repository into your local branch. It is used to sync your local repository with changes from others working on the same project.

Error Explanation: The error message There is no tracking information for the current branch occurs because the current branch doesn't know which remote branch it should pull changes from. Git is asking you to specify a remote and a branch for pulling.

Correcting the Process To resolve this, you need to either:

Specify the Remote and Branch in the Pull Command:

Example: git pull origin master

This command tells Git to pull changes from the master branch of the origin remote repository.

Set Upstream Tracking for the Branch:

Command: git branch --set-upstream-to=/ master Example: git branch --set-upstream-to=origin/master master

This sets the master branch to track the master branch on the remote repository (origin), so you won’t need to specify the branch every time you run git pull.

3. GIT PUSH

Command: git push

Description: Pushes your committed changes from the local repository to the remote repository (like GitHub).

Explanation of the Command Git Push Command

Purpose: The git push command is used to upload local commits to a remote repository (like GitHub or GitLab). It sends the changes from your local branch to the corresponding branch in the remote repository.

Error Explanation: The error fatal: No configured push destination occurs because Git doesn’t know where to push your changes. There is no remote repository configured yet. Git is instructing you to either add a remote repository or specify the push destination manually.

Correcting the Process To fix this, you need to either:

Add a Remote Repository:

Command: git remote add

Example: git remote add origin https://github.com/username/repo.git

This command adds a remote repository and names it origin. Once the remote is set, you can push changes using git push origin master.

Push Using the Remote Name:

Command: git push

Example: git push origin master This command pushes the master branch to the origin remote repository.

4. GIT LOG

Command: git log

Description: Displays a list of commits made in the current branch.

Explanation of the Command Git Log Command

Purpose:

The git log command is used to view the commit history in a Git repository. It shows a list of commits along with details like commit hash, author, date, and commit message.

Error Explanation:

The error fatal: your current branch 'master' does not have any commits yet occurs because there haven’t been any commits made on the master branch. You need at least one commit for the log to display history.

Correcting the Process To resolve this, you need to make a commit:

Stage and Commit Files:

Command: git add . git commit -m "Initial commit"

This will stage all the files in your directory and commit them with the message “Initial commit.”

5. GIT ADD

Command: git add or git add .

Description: Stages file changes to be committed. Use . to stage all changes in the directory.

This output shows the result of running the git add . command when there are permission issues and line-ending conversions.

Command: git add .

Purpose:

Stages all changes in the current directory for the next commit.

Warnings:

Permission Denied: Git can't access certain system directories (e.g., AppData/, Documents/). These are system-specific and not usually part of a repository. You can ignore these warnings or exclude them using .gitignore.

LF to CRLF:

Git converts line endings from LF (Unix) to CRLF (Windows). This is normal on Windows and ensures compatibility across platforms.

Solution:

Use .gitignore: Add system directories to .gitignore to avoid these warnings.

AppData/ Documents/

Handle Line Endings: Run this command to configure Git to automatically manage line endings:

git config --global core.autocrlf true

6. GIT STATUS

Command: git status

Description: Shows the current status of your files and what changes have been staged for commit.

This output shows the result of running the git status command with permission issues and untracked files.

Purpose:

Shows the current state of the working directory, including changes that are staged, unstaged, and untracked files.

Warnings:

Permission Denied:

Git cannot access system directories like AppData/, Documents/, etc. These directories are system-related and can be safely ignored or excluded using .gitignore.

Untracked Files:

Lists the files that haven’t been added to the Git repository yet (e.g., .gitignore, .android/). You can stage them using git add .

Solution:

Exclude system directories:

Add these directories to .gitignore:

AppData/ Documents/

Stage Untracked Files: Use git add to track the necessary files.

This is a common scenario when working with Git on Windows systems.

7. GIT CLONE

Command: git clone

Description: Clones a remote repository to your local machine.

This output shows the result of running the git clone command without specifying a repository.

Purpose:

Clones an existing Git repository from a remote server to your local machine.

Error Explanation:

Fatal Error: "You must specify a repository to clone." This occurs because the git clone command requires a repository URL to proceed.

Correct Usage:

To clone a repository, you need to provide the repository URL, like this:

git clone

For example:

git clone https://github.com/username/repo.git This will copy the remote repository to your local machine.

8. GIT BRANCH

Command: git branch

Description: Lists all branches or creates a new branch if followed by a branch name.

The git branch command has no output in this case because there are no branches created yet in your repository.

Purpose:

Lists all branches in the current repository and highlights the currently checked-out branch.

Explanation:

No Output: This means you are in a repository without any branches. The default branch (usually master or main) has not been initialized yet because no commits have been made.

Next Steps:

To create and switch to a new branch:

git checkout -b

Alternatively, make your first commit on the current branch to see it listed:

git commit -m "Initial commit"

LINK TO MY MEDIUM: https://medium.com/@monettenicolas069/activity-3-github-fundamentals-5cbe32652ed1