How To Open Git Bash On Windows
Git Bash is an application that provides Git command line feel on the Operating System. It is a control-line shell for enabling git with the command line in the arrangement. A shell is a terminal application used to interface with an operating arrangement through written commands. Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating organisation. In Git Bash the user interacts with the repository and git elements through the commands.
What is Git?
- Git is version-control system for tracking changes in source code during software development.
- It is designed for coordinating piece of work among programmers, but it can be used to rails changes in whatsoever set of files.
- Its goal is to increase efficiency, speed and easily manage large projects through version decision-making.
- Every git working directory is a full-fledged repository with consummate history and total version-tracking capabilities, contained of network admission or a central server.
- Git helps the team cope up with the confusion that tends to happen when multiple people are editing the same files.
Installing Git Bash
Follow the steps given beneath to install Git Bash on Windows:
Step 1: The .exe file installer for Git Bash can exist downloaded from https://gitforwindows.org/
In one case downloaded execute that installer, following window will occur:-
Footstep 2: Select the components that you need to install and click on the Next button.
Footstep 3: Select how to use the Git from control-line and click on Next to brainstorm the installation procedure.
Step iv: Let the installation process finish to brainstorm using Git Fustigate.
To open Git Bash navigate to the folder where you have installed the git otherwise only simply search in your OS for git bash.
Navigate in Git Bash
cd command
cd command refers to change directory and is used to get into the desired directory.
To navigate between the folders the cd command is used
Syntax:
cd folder_name
ls command
ls command is used to list all the files and folders in the current directory.
Syntax:
ls
Set your global username/email configuration
Open Git Fustigate and begin creating a username and email for working on Git Fustigate.
Set your username:
git config --global user.name "FIRST_NAME LAST_NAME"
Gear up your email address:
git config --global user.email "MY_NAME@example.com"
Initializing a Local repository
Follow the steps given below to initialize your Local Repository with Git:
Stride i: Make a repository on Github
Step 2: Give a suitable name of your repository and create the repository
Notation: You lot tin choose to initialize your git repository with a README file, and farther, you can mention your project details in it. Information technology helps people know what this repository is about. However, it's absolutely not necessary. Merely if you practice initialize your repo with a README file using interface provided by GitHub, so your local repository won't have this README file. Then to avoid running into a snag while trying to push your files (as in footstep three of side by side section), after step five (where y'all initialize your local folder every bit your git repository), practice following to pull that file to your local folder:
git pull
Step 3: The post-obit volition appear after creating the repository
Footstep 4: Open Git Bash and change the electric current working directory to your local project by use of cd control.
Step 5: Initialize the local directory as a Git repository.
git init
Step half-dozen: Stage the files for the first commit by adding them to the local repository
git add together .
Stride seven: Past "git condition" y'all can see the staged files
Step eight: Commit the files that you've staged in your local repository.
git commit -m "First commit"
Now After "git status" control it can be seen that zip to commit is left, Hence all files have been committed.
Push button files to your Git repository
Step i: Go to Github repository and in code section copy the URL.
Step two: In the Command prompt, add the URL for your repository where your local repository will be pushed.
git remote add origin repository_URL
Step 3: Push the changes in your local repository to GitHub.
git push origin master
Here the files have been pushed to the master branch of your repository.
At present in the GitHub repository, the pushed files can be seen.
Saving changes to local repository
Suppose the files are beingness changed and new files are added to local repository.
To save the changes in the git repository:
Step 1: Changes have to be staged for the commit.
git add .
or
git add together file_name
Step 2: At present commit the staged files.
git commit -thou "commit_name"
Step 3: Push button the changes.
git push origin main
New changes can exist seen
Branching through Git Bash
Branching in Github
Suppose if a squad is working on a project and a branch is created for every member working on the project.
Hence every fellow member will piece of work on their branches hence every time the best branch is merged to the master branch of the projection.
The branches make it version controlling organization and makes it very easy to maintain a project source code.
Syntax:
- List all of the branches in your repository.
git branch
- Create a new branch
git branch branch_name
- Safe Delete the specified branch
git co-operative -d branch_name
- Force delete the specified branch
git branch -D branch_name
Navigating betwixt Branches
To navigate between the branches git checkout is used.
To create create a new branch and switch on it:
git checkout -b new_branch_name
To simply switch to a branch
git checkout branch_name
Subsequently checkout to co-operative you tin can run into a * on the current branch
Now the same commit add
and commit actions
tin be performed on this branch besides.
Merge whatever 2 branches
To merge a branch in whatsoever branch:
- First reach to the target branch
git checkout branch_name
- Merge the branch to target branch
git merge new_branch
Cloning Repository to arrangement
Cloning is used to get a copy of the existing git repository.
When yous run the git clone control it makes the zip folder saved in your default location
git clone url
This command saves the directory as the default directory name of the git repository
To salve directory proper name as your custom name an boosted statement is to exist passed for your custom name of directory
git clone url custom_name
Undoing commits
When in that location is a situation when you forget to add some files to commit and want to undo any commit, it can be commit over again using --ammend
Syntax:
git commit --ameliorate
Determination
- To conclude it tin can be said that git bash is a command line platform which helps in enabling git and its elements in your system.
- There are a bunch of commands which are used in git bash.
- Git Bash is very like shooting fish in a barrel to use and makes it piece of cake to work on repositories and projects.
How To Open Git Bash On Windows,
Source: https://www.geeksforgeeks.org/working-on-git-bash/
Posted by: conklinlosetto.blogspot.com
0 Response to "How To Open Git Bash On Windows"
Post a Comment