GitHub_Report
GitHub_Report
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
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
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
AIM:
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
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 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
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>
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
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.