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

Git and Github

Uploaded by

rakeshsivan08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Git and Github

Uploaded by

rakeshsivan08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Name: Rakesh Sivan S

Ref no.: 24900385


Dept: ECE first year

1.To create a new directory named git-workshop and navigate into it, you can use
these commands in the terminal:
mkdir git-workshop -->Creates a new directory named 'git-workshop'
cd git-workshop -->to navigate into the 'git-workshop' directory

2.To initialize a Git repository in your current directory:


git init

3.You can create a new file named hello.txt and add the content "Hello Git
workshop!":
echo "Hello!" > hello.txt

4.To display the status of your Git repository:


git status

5.i)To stage the file hello.txt:


git add hello.txt

ii)To commit the staged file with the message "Add hello.txt with welcome
message":
git commit -m "Add hello.txt with welcome message"

6.i)To create a new branch named update-content:


git branch update-content

ii)To switch to the update-content branch:


git checkout update-content

7.i)To append the text "This is a simple Git assignment." to hello.txt:


echo "This is a simple Git assignment." >> hello.txt
ii)To stage and commit the changes to hello.txt with the message "Update
hello.txt with additional message:
git commit -m "Update hello.txt with additional message"

8.i)To switch back to the main branch:


git switch main
ii)To merge the update-content branch into the main branch:
git merge update-content

9.To show the commit history of your Git repository:


git log

10.i)If you want to revert changes made to hello.txt before committing :


git restore hello.txt
ii)to reset your branch to a previous commit:
git reset --soft <commit_hash>

11.i)to command adds a remote repository named `origin`:


git remote add origin https://github.com/username/repository.git
ii)To push your local main branch to the remote repository:
git push

You might also like