banner



How To Git Bash On Windows

Git Bash is an application that provides Git command line experience on the Operating System. It is a control-line shell for enabling git with the control line in the system. A shell is a terminal application used to interface with an operating system through written commands. Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating organization. In Git Bash the user interacts with the repository and git elements through the commands.

What is Git?

  • Git is version-command system for tracking changes in source lawmaking during software development.
  • It is designed for coordinating work amidst programmers, but it tin be used to track changes in any set up of files.
  • Its goal is to increase efficiency, speed and hands manage large projects through version controlling.
  • Every git working directory is a total-fledged repository with consummate history and full version-tracking capabilities, independent 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 aforementioned files.

Installing Git Bash

Follow the steps given below to install Git Bash on Windows:

Footstep 1: The .exe file installer for Git Bash can exist downloaded from https://gitforwindows.org/
Once downloaded execute that installer, post-obit window will occur:-

Footstep 2: Select the components that you need to install and click on the Next button.

Step iii: Select how to use the Git from control-line and click on Adjacent to brainstorm the installation process.

Footstep 4: Let the installation process finish to brainstorm using Git Bash.

To open Git Bash navigate to the folder where you take installed the git otherwise but merely search in your Os for git bash.

Navigate in Git Bash

cd command

cd control refers to change directory and is used to get into the desired directory.

To navigate betwixt the folders the cd control 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 brainstorm creating a username and email for working on Git Bash.

Set your username:

git config --global user.name "FIRST_NAME LAST_NAME"

Prepare your email address:

git config --global user.email "MY_NAME@example.com"

Initializing a Local repository

Follow the steps given beneath to initialize your Local Repository with Git:

Pace i: Make a repository on Github

Step 2: Give a suitable name of your repository and create the repository

Annotation: Y'all can choose to initialize your git repository with a README file, and further, you lot can mention your project details in it. It helps people know what this repository is nearly. Yet, information technology's absolutely not necessary. But if yous exercise initialize your repo with a README file using interface provided by GitHub, then your local repository won't have this README file. Then to avoid running into a snag while trying to push your files (equally in step three of next section), later on step 5 (where yous initialize your local folder as your git repository), do following to pull that file to your local folder:

git pull                  

Step 3: The following will announced later on creating the repository

Step 4: Open up Git Bash and change the current working directory to your local projection by use of cd command.

Step 5: Initialize the local directory as a Git repository.

          git init        

Step 6: Stage the files for the first commit by adding them to the local repository

git add together .

Step vii: By "git status" you can see the staged files

Stride 8: Commit the files that you lot've staged in your local repository.

git commit -m "First commit"

Now After "git condition" command it tin be seen that nothing to commit is left, Hence all files have been committed.

Push files to your Git repository

Step 1: Become to Github repository and in code department copy the URL.

Footstep 2: In the Command prompt, add the URL for your repository where your local repository will exist pushed.

git remote add together origin repository_URL

Step three: Push the changes in your local repository to GitHub.

git push button origin master

Here the files have been pushed to the principal 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 being inverse and new files are added to local repository.
To relieve the changes in the git repository:
Step 1: Changes have to be staged for the commit.

git add .

or

git add file_name

Pace 2: Now commit the staged files.

git commit -one thousand "commit_name"

Stride 3: Button the changes.

git button origin master

New changes tin can be seen

Branching through Git Bash

Branching in Github

Suppose if a squad is working on a project and a co-operative is created for every member working on the project.
Hence every member will work on their branches hence every time the best branch is merged to the main branch of the project.
The branches make it version decision-making organisation and makes it very easy to maintain a project source lawmaking.

Syntax:

  • List all of the branches in your repository.
    git branch
  • Create a new branch
    git branch branch_name
  • Safety Delete the specified co-operative
    git co-operative -d branch_name
  • Strength 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 co-operative

git checkout branch_name

After checkout to branch you can run into a * on the current branch

Now the aforementioned commit add and commit actions can be performed on this co-operative also.

Merge any 2 branches

To merge a co-operative in any branch:

  • First achieve to the target branch
    git checkout branch_name
  • Merge the branch to target branch
    git merge new_branch

Cloning Repository to system

Cloning is used to get a copy of the existing git repository.
When you run the git clone command information technology makes the null folder saved in your default location

git clone url

This control saves the directory as the default directory proper noun of the git repository
To save directory name every bit your custom name an additional statement is to be passed for your custom name of directory

git clone url custom_name

Undoing commits

When there is a situation when you forget to add some files to commit and desire to disengage whatsoever commit, information technology can exist commit once again using --ammend

Syntax:

git commit --amend

Conclusion

  • To conclude it tin exist said that git bash is a command line platform which helps in enabling git and its elements in your organisation.
  • In that location are a bunch of commands which are used in git bash.
  • Git Bash is very easy to use and makes it easy to piece of work on repositories and projects.

Source: https://www.geeksforgeeks.org/working-on-git-bash/

Posted by: mundyacto1941.blogspot.com

0 Response to "How To Git Bash On Windows"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel