Dharmavir - 12323255 - Blind Short 1M

Download as zip, pdf, or txt
Download as zip, pdf, or txt
You are on page 1of 5

Dharmavir kumar singh

Roll-no =70
12323258

Q2.

To upload a project to GitHub using Git, follow these steps:

### Prerequisites:
1. **Install Git** on your machine. If you haven't installed Git yet, you can download it from [here](https://git-scm.com/downloads).
2. **Create a GitHub account** if you don't already have one.
3. **Create a repository on GitHub**:
- Go to GitHub.
- Click on the **+** button at the top-right corner and select **New repository**.
- Name your repository (e.g., `my-project`).
- Choose the visibility (Public or Private).
- **Don't** initialize the repository with a README (since you’ll add your own files).

### Steps to Upload a Project to GitHub Using Git

#### 1. **Navigate to your project directory**


Open the terminal and navigate to the folder where your project is located using the `cd` command.
```bash
cd path/to/your/project
```

#### 2. **Initialize the Git repository**


Initialize Git in your project folder if you haven’t done so already:
```bash
git init
```
This command initializes a new Git repository in your project folder. You will now be able to track changes to your project using Git.

#### 3. **Add files to the staging area**


Add all the files in your project to Git’s staging area:
```bash
git add .
```
The `.` means "add all files." This stages your files so they can be committed to the repository.

#### 4. **Commit the changes**


Commit the staged files to your local repository with a descriptive message. A commit is a snapshot of your project at a specific
time.
```bash
git commit -m "Initial commit"
```

#### 5. **Add the GitHub repository as a remote**


You need to link your local Git repository to the remote GitHub repository. Replace `your-username` and `your-repository` with your
actual GitHub username and the name of the repository you created.
```bash
git remote add origin https://github.com/your-username/your-repository.git
```
This command sets `origin` as the remote repository you will be pushing your code to.

#### 6. **Push the changes to GitHub**


Push your code to the GitHub repository using the `git push` command. The `-u` flag sets the default upstream for future pushes
(meaning, after the first push, you can just type `git push` without specifying the branch).
```bash
git push -u origin master
```
This command pushes the local `master` branch to the remote repository named `origin`.

#### 7. **Verify your project on GitHub**


Go to your GitHub repository URL (e.g., `https://github.com/your-username/your-repository`) and refresh the page. You should now
see your project files uploaded to the repository.

### Optional Steps


- **Create a `.gitignore` file**: You may want to create a `.gitignore` file to exclude certain files or directories (such as
`node_modules`, temporary files, etc.) from being tracked by Git. Create a `.gitignore` file in your project’s root directory and
specify the files you want to exclude.

Example `.gitignore`:
```bash
# Ignore node_modules folder
node_modules/

# Ignore temporary files


*.log
```

- **Push to a different branch**: If you prefer working on a separate branch (e.g., `main` or `development`), you can create and
push to a different branch:
```bash
git checkout -b main # Creates and switches to 'main' branch
git push -u origin main # Pushes the 'main' branch to GitHub
```
Now your project is uploaded to GitHub, and you can continue pushing updates or collaborating with others!

Q3

Q3.
Step1
The ls command in Linux is used to list the contents of a directory. When you run ls in the terminal, it displays the files
and directories in the current working directory.

Step2.
Mkdir
In Linux, mkdir stands for "make directory." It is a command used to create new directories (or folders) in the file
system.
Step 3.
Touch is a command used primarily to create empty files or update the timestamps of existing files (access and
modification times). It is commonly used in scripting and file management.

Step 4.

In Linux, the echo command is used to display a line of text or a string on the terminal. It's a simple but frequently used
command for printing output, often in shell scripts.

You might also like