0% found this document useful (0 votes)
1 views

GitHub_Report

dfbdsnsrb

Uploaded by

Arnil Dsouza
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)
1 views

GitHub_Report

dfbdsnsrb

Uploaded by

Arnil Dsouza
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/ 11

1

EXPERIMENT No. 01: Setting Up and Basic Commands

AIM:
Initialize a new Git repository in a directory. Create a new file and add it to the stagingarea and commit
the changes with an appropriate commit message

COMMANDS:
1. git init
2. git clone “remote repository link”
3. git add .
4. git commit -m “message”
5. git push

PROCEDURE AND RESULTS:


 Create a new directory and initialize a new Git repository in the current directory using the
command - git init
 Clone a previously existing remote repository using the command - git clone “ remote repository
link”
 Navigate to the cloned repository using the command - cd “ remote repository name”
 Make any required changes by adding a folder or a file
 Stage the changes applied using the command - git add .

 Record the changes applied that have been staged using the command - git commit -m
“message” with an appropriate message
 Push the changes recorded into the remote repository using the command using the command
– git push
2

EXPERIMENT No. 02: Creating and Managing Branches

AIM:
a. Create a new branch named “feature-branch”. Switch to the “master” branch.Merge the
“feature-branch” into “master”.
b. Write the commands to stash your changes, switch branches, and then apply the stashed
changes.

COMMANDS:
1. git branch feature_branch_name
2. git checkout master/main
3. git merge feature_branch_name
4. git checkout feature_branch_name
5. git stash
6. git stash apply

PROCEDURE AND RESULTS:


a.
 Create a new branch using the command - git branch feature_branch_name
 Navigate to the new branch created using the command –
git checkout feature_branch_name
 Make any required changes, stage the changes and commit them with an appropriate
message
 Navigate to the main branch using the command - git checkout main
 Merge the changes made into the main branch using the command –
git merge feature_branch_name
3

b.
 Navigate to the feature_branch
 Make any required changes, stash them using the using the command – git stash
 Navigate to the main branch and make any required changes and stage and commit them.
 Now go back to the feature_branch. If you want the stashed changes to be reflected, use
the command – git stash apply.
 Later, these changes can be staged and committed.
4

EXPERIMENT No.03: Collaboration and Remote Repositories

AIM:

a. Clone a remote Git repository to your local machine.


b. Fetch the latest changes from a remote repository and rebase your local branch onto the
updated remote branch.
c. Write a command to merge “feature-branch” into “master” while providing a custom
commit message for the merge.
COMMANDS:
1. git clone <repository_url>

2. git checkout -b feature-branch

3. git fetch origin


4. git rebase origin

5. git merge --no-ff feature-branch -m "Custom commit message"

PROCEDURE AND RESULTS:


a.
 To clone a remote repository, use the command – git clone <repository_url>
5

b.
 To fetch the latest changes in the remote repository into your local repository, use the
command - git fetch origin
 To merge the fetched changes onto your current working branch, use the command -git
rebase origin

c.
 Navigate to the main branch
 To merge the feature-branch into the current branch without fast-forwarding, use the
command – git merge –no-ff feature_branch -m “Commit message” with suitable
message
6

EXPERIMENT No.04: Git Tags and Releases

AIM:
Write the command to create a lightweight Git tag named "v1.0" for a commit in yourlocal repository.

COMMANDS:
1. git log
2. git tag <tag_name>
3. git show < tag_name >
4. git push origin < tag_name>
PROCEDURE AND RESULTS:

 To view the commit history, use the command - git log


7

 To create a lightweight Git tag, use the command - git tag <tag_name>

 To verify that the tag was created correctly and is pointing to the desired commit, use the
command – git show <tag_name>

 To push the tag onto the remote repository, use the command - git push origin < tag_name>
8

EXPERIMENT No.05: Advanced Git Operations

AIM:
Write a command to cherry-pick a range of commits from "source-branch" to the current branch.

COMMANDS:
1. git checkout -b new_branch_name
2. git add .
3. git log –oneline
4. git cherry-pick <commit_id>

PROCEDURE AND RESULTS:


 To create a new branch and navigate to it, use the command - git checkout -b
new_branch_name
 To stage the changes in all files and folders within the branch, use the command – git add .
 Later commit them with appropriate message.
 To view each of the commits in commit history in a single line, use the command –
git log –oneline
 Copy the commit_id to cherry pick.
 Navigate to the main branch.

 Now perform the cherry-pick operation by using the command git cherry-pick <commit_id>
9

EXPERIMENT 6: Analyzing and Changing Git History

AIM:

a. Given a commit ID, how would you use Git to view the details of that specific commit,
including the author, date, and commit message?
b. Write the command to list all commits made by the author "JohnDoe" between"2023-01-
01" and "2023-12-31."
c. Write the command to display the last five commits in the repository's history.
d. Write the command to undo the changes introduced by the commit with the ID"abc123".

COMMANDS:
1. git show <commit_id>
2. git log --author=<Username> --after=<start_date> --before<stop_date>.
3. git log -n
4. git revert abc123

PROCEDURE AND RESULTS:

 To find the details of a particular commit with its associated commit id by using the command
- git show <commit id>
10

 To find the details of all the commits done by an author during a particular time interval, use
the command - git log --author=Username --after=<start_date> --before<stop_date>.

 To find the list of the last m commits, staged by the user, use the git log -n m.
11

 To undo the changes introduced by the commit with a particular id, use the command - git
revert <commit_id> , where <commit_id> is the id of the commit to be reverted.

You might also like