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

How to Use Git Commands

This document provides a step-by-step guide for setting up Git, including downloading, installing, and configuring SSH keys. It also outlines the process for cloning a project, creating a local branch, and making a pull request. Additionally, it includes commands for managing changes and collaborating on GitHub.

Uploaded by

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

How to Use Git Commands

This document provides a step-by-step guide for setting up Git, including downloading, installing, and configuring SSH keys. It also outlines the process for cloning a project, creating a local branch, and making a pull request. Additionally, it includes commands for managing changes and collaborating on GitHub.

Uploaded by

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

Page 1

Git Setup
1. Download Git
For windows:
https://git-scm.com/download/win
For mac:
https://git-scm.com/download/mac

2. Install Git & Set SSH key


a. How to Generate SSH key:
ssh-keygen -t rsa -b 4096 -C [email protected]

b. Open Key in GitBash :


cat ~/.ssh/id_rsa.pub

c.Add Your SSH key on your GitHub Account


Settings > SSH & GPG Keys > New key > Enter copied value > Add new Key

d.Set your name & email address on your machine through gitbash :
git config --global user.email "[email protected]"
git config --global user.name "Your Name"

3. Accept invitation & Clone project


a. Accept invitation
b. You have received an email with the title below
Note: Click on View Invitation button from email account. (Make sure you are logged
in from your GitHub account or it will through 404 error.)
https://github.com/harshvegada/APR25_Java (Bookmark this url)
c. Go to this url & Click on Code > Click on SSH > Copy ssh key
d. Open Git Bash in your machine where you want to upload project
And Enter this command:
git clone [email protected]:harshvegada/APR25_Java.git
e. Press enter.
f. Once Project is clone in your machine Import in eclipse.

4. Import project in Eclipse

5. Create & Switch to your Local Branch from master/main branch


a. Open gitbash where src folder is available.
b. Enter below command:
git checkout -b “YOURName_Branch1”
Note: Now you will switch on your branch and also in eclipse you are able to see your branch.

How to use git commands Contact us: 9561690681


Page 2

How to create your first pull-request

1. Open GitBash in your respective project where the src folder is available.
2. You must be on your main or master branch, hit below command to make your master up to
date with Github master:
git pull origin master

3. Create new local branch from main/master branch always:


git checkout -b <branch name>

2. Go to Eclipse, and add one assignment.

3. Go to GitBash and hit the below command.


To check what changes you have made in the current branch hit below command:
git status

4. If your changes are as per expected > add them or remove them.
For adding your file, the command is : git add <fileName>
If your changes are not valid and you don’t want to add that file and changes:
git checkout <fileName>

5. If you want to remove your file from add state(Green state) :


git reset <yourFileName>

6. For committing your changes:


git commit -m “<Your commit message>”

7. Now it’s time to push your file and your local branch:
git push --set-upstream origin <Your Branch name>

8. Create pull requests from your branch.

9. Add a screenshot of your code execution.

10. Add a reviewer for your pull request.

11. Now send a pull request URL to your reviewer and request their review.

You are appreciated for reading this. ●


Wishing you a wonderful learning experience in the future.

How to use git commands Contact us: 9561690681

You might also like