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

Git and GitHub Full Guide

git hub

Uploaded by

Routhu hemalatha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Git and GitHub Full Guide

git hub

Uploaded by

Routhu hemalatha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

First we have to install git client

https://git-scm.com/downloads

create one folder in you laptop


then open git bash and fallow below commands

create git hub account


https://github.com/
you have create one organization and one repository in GitHub

touch lend.txt
git init
git add lendi.txt
git commit -m “new file”
git branch -M main
git remote add origin https://github.com/yannan-123/sample.git
git push -u origin main

next change simple fallow below steps

git status
git add .
git commit -m “first”
git push

Git Basics

Git is a distributed version control system used to track changes in source


code during software development. Below are essential Git commands:
Configuration

1. Set user name and email globally:

git config --global user.name " lendivasanth "


git config --global user.email " vasanthd374@gmail.com"

2. Check the current configuration:

git config --list

3. Set up an alias (optional):

git config --global alias.co checkout

Repository Management

1. Initialize a repository:

git init

2. Clone a repository:

git clone <repository-url>

3. Add files to the staging area:

git add <file-name>

Add all files:

git add .

4. Commit changes:

git commit -m "Commit message"

5. Check the status of your working directory:

git status
6. View commit history:

git log

7. View a summary of the commit history:

git log --oneline

8. Undo changes before committing:

git checkout -- <file-name>

9. Remove files from the staging area:

git reset <file-name>

10.Undo a commit (soft reset):

git reset --soft HEAD~1

Branching

1. Create a new branch:

git branch <branch-name>

2. Switch to a branch:

git checkout <branch-name>

3. Create and switch to a new branch:


git checkout -b <branch-name>

4. List all branches:

git branch

5. Merge a branch into the current branch:

git merge <branch-name>

6. Delete a branch:

git branch -d <branch-name>

Collaboration (Pushing/Pulling)

1. Push changes to a remote repository:

git push origin <branch-name>

2. Pull changes from a remote repository:

git pull

3. Fetch changes without merging:

git fetch
4. Check the remote repository URL:

git remote -v

Stashing

1. Stash changes (save them temporarily):

git stash

2. Apply the last stashed changes:

git stash apply

3. List stashed changes:

git stash list

4. Drop a specific stash:

git stash drop stash@{n}

Tagging

1. Create a new tag:

git tag <tag-name>


2. Push a tag to the remote repository:

git push origin <tag-name>

3. List all tags:

git tag

4. Delete a tag locally:

git tag -d <tag-name>

GitHub Basics

GitHub is a cloud-based hosting service that helps manage Git repositories.


Below are key concepts and commands for GitHub.

1. Create a new repository on GitHub:


o On GitHub, go to Repositories > New and create a new
repository.

2. Add a remote repository:

git remote add origin <repository-url>

3. Push to a remote repository (first push):

git push -u origin master

4. Fork a repository:
o Click the Fork button on GitHub to create your copy of a
repository.

5. Create a pull request:


o After pushing changes to your forked repository, create a pull
request on GitHub by navigating to Pull Requests > New Pull
Request.

6. Clone a GitHub repository:

git clone https://github.com/username/repository.git

Working with Issues and Pull Requests

1. Create a new issue:


o On GitHub, go to the Issues tab > New Issue and describe the
problem or request.

2. View pull requests:


o Navigate to the Pull Requests tab to view open pull requests.

GitHub Actions (CI/CD)

GitHub Actions is used to automate tasks like building, testing, and


deploying code.

1. Create a new workflow:


o In the repository, go to Actions > New Workflow, and select a
template to configure automated tasks.

2. Push a workflow YAML file:


o Create a .github/workflows/main.yml file in your repository and
configure tasks for CI/CD.
Additional Tips

 Git Ignore:
To exclude files from being tracked, create a .gitignore file in your
repository with the names or patterns of files to ignore.
 Resolving Merge Conflicts:
When you encounter merge conflicts:

git merge <branch-name>


# Then edit conflicting files, resolve conflicts manually.
git add <resolved-file>
git commit

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy