Git Topics
- Initializing a Git Repository
- Creating a New Branch
- Initializing a Local Git Repository
- Adding and Committing Changes
- Adding Files to Staging Area
- Committing Changes to Local Repository
- Creating and Managing Branches
- Switching to a Newly Created Branch
- Creating and Renaming Branches
- Connecting to Remote Repositories
- Adding a Remote Repository
- Pushing Changes to Remote Repositories
- Git Configuration
- Setting User Information
- Global Configuration Options
- Advanced Git Commands
- Viewing Commit History
- Inspecting Changes with
git show
- Resolving Conflicts
Git Commands
Creating a New Branch
To switch to a newly created branch:
git checkout -b <branch-name>
BashInitializing a Local Git Repository
Create a new project directory:
mkdir newproject
cd newproject
BashCreate a new file (README.md
in this example):
echo "# create new file #" >> README.md
BashInitialize Git in the local repository:
git init
BashAdding and Committing Changes
Add the file to the staging area:
git add README.md
BashCommit changes to the local repository:
git commit -m "first commit"
BashCreating and Pushing to Main Branch
Create the main branch:
git branch -M main
BashConnect to a remote repository and push changes:
git remote add origin <remote-url>
git push -u origin main
BashPractice Task
Jenkins and Selenium Setup
Jenkins Status Check
To check Jenkins status:
sudo service jenkins status
BashSelenium Installation
Locate Selenium:
locate selenium
BashInstall Selenium:
sudo apt install mlocate
sudo apt-get update
sudo pip install selenium
BashGit Configuration
Setting Git User Information
Configure Git with your username and email:
git config --global user.name "temp"
git config --global user.email "[email protected]"
BashAdditional Git Commands
- Initialize a Git repository:
git init
BashCheck repository status:
git status
BashView commit history:
git log
BashPush changes to a remote repository:
git push -u origin master
BashAuthor: TCF Editorial
Copyright The Cloudflare.
You may also read: