banner



How To Run Git Clone Command On Windows

How to install and apply Git on Windows

Updated: 06/30/2020 by Computer Hope

Git on Windows

Past default, Git is installed on Linux and macOS computers as a command line option. However, Microsoft Windows does non include a Git command. Below are the steps on how to install and use Git and GitHub on Microsoft Windows.

Installing Git on Windows

  1. Open the Git website.
  2. Click the Download link to download Git. The download should automatically kickoff.
  3. In one case downloaded, commencement the installation from the browser or the download binder.
  4. In the Select Components window, exit all default options checked and bank check whatsoever other boosted components you lot want installed.
  5. Next, in the Choosing the default editor, used by Git unless you're familiar with Vim we highly recommend using a text editor you lot're comfy using. If Notepad++ is installed, we suggest using it as your editor. If Notepad++ is not installed, you lot can cancel the install and install Notepad++ and then restart the GitHub install.
  6. Next, in the Adjusting your PATH environment, we recommend keeping the default Apply Git from the command line and also from third-party software as shown below. This option allows you lot to use Git from either Git Bash or the Windows Command Prompt.

Git install adjust path

  1. Next, we recommend leaving the default selected as Utilise OpenSSH.
  2. Next, in Choosing HTTPS transport backend, leave the default Apply the OpenSSL library selected.
  3. In the Configuring the line ending conversions, select Checkout Windows-style, commit Unix-fashion line endings unless you need other line endings for your piece of work.
  4. In the Configuring the terminal emulator to use with Git Bash window, select Use MinTTY (the default terminal of MSYS2).
  5. On the Configuring actress options window, leave the default options checked unless you need symbolic links.
  6. Click the Install button
  7. Once completed, you can check the option to Launch Git Bash if you want to open a Fustigate control line or, if you selected the Windows command line, run Git from the Windows command line.

Tip

We highly recommend you use Git from the control line and not use a GUI interface. You'll only be using the command line to interface with Git to manage the files. Editing tin can still exist done through a text editor or IDE of your pick. If you're new to the control line, you can detect help with navigating the Windows command line and Linux (Bash) through the links below.

  • How to use the Windows command line (DOS).
  • Linux trounce tutorial.

Configuring and connecting to a remote repository

In our case, nosotros're using GitHub every bit a storage for our remote repository. Below are the steps on how you can connect to a GitHub repository. If yous are new to GitHub, see: How to create a GitHub repository.

  1. From the control line, move to the directory y'all want to contain your Git repository.
  • How to alter a directory or open a folder.
  1. Blazon the post-obit command to configure your Git username, where <your name> will be your GitHub username.
git config --global user.name "<your name>"
  1. After entering the to a higher place control, you'll exist returned to the control prompt. Side by side, enter your electronic mail address by typing the following command, where <your electronic mail> is your email accost.
git config --global user.email "<your due east-mail service>"
  1. One time the above steps are completed, you lot'll be prepare to connect to a remote repository. To discover the repository accost, go to a repository on GitHub and click the Clone or download repository link to become the address. For case, we've created a repository called "example" at https://github.com/Computerhope/instance.git address. Copy the address to your clipboard.
  2. Once copied go back to the command line and type the following command, where <URL> is the address you copied. To paste that address into the command line right-click in the command line window and click paste.
git clone <URL>
  1. Once the Git repository is created, you'll accept a new directory in your current directory with the name of the Git repository.
  2. In one case the Git remote repository is cloned to your local repository, a new folder in the current directory should appear with the proper name of the Git repository. For case, in our "example" Git nosotros would take a new directory chosen "example". Use the cd command to alter into the new directory.
  3. Once in the new directory, type the following control to list the remote repositories.
git remote
  1. If successful, the output is "origin," which is a special proper noun that refers to the remote repository.
  2. To see the aliases (URL or path), type the following control.
git remote -5

Running each of the above commands give you an output similar to what is shown in our instance below.

Git listing remote repositories

Now that you've continued to a remote repository on GitHub you're ready to start working on the files and pushing and pulling files as yous update the files.

Working in your local repository and pushing files

Subsequently post-obit the above steps and cloning a remote repository, y'all can piece of work on the files as y'all unremarkably would. You can create new files or edit existing files from the command line or your favorite text editor. Beneath, are the steps of creating a new file, pushing that file, editing an existing file, and pushing the update.

Creating a new file and pushing to remote repository

  1. Create a new file in the Git directory past typing the following control from either the Bash or Windows control line. The following command opens and creates a file called example.txt in Notepad. In Git Bash, you could also apply the touch command to create a blank new file so blazon "showtime <proper noun of file>" to open the file in your favorite text editor.
offset notepad example.txt
  1. In the text editor, enter some text into the file and salve and exit the file.
  2. Dorsum at the command line type the post-obit control to get the electric current status of your branch and untracked files.
git status
  1. Git displays a window like to the example shown below, showing that the file we created is new and untracked by Git.

Git status

  1. Nosotros'll now want to add together this file to Git to exist tracked by typing the following command. If your file is not named "case.txt," you'd want to change the text to the proper noun of your file.
git add example.txt
  1. After entering the above command, the file is added as a new file also known as staging. Typing git status again shows yous in dark-green that the file is a new file that is ready to exist committed.
  2. Adjacent, type the post-obit command to commit the changes made in the local workspace to the local repository. In the instance below, our notes "Commencement example" should be notes that would make sense everyone working on your project.
git commit -one thousand "First example"

Note

You can also type git commit with no additional tags or options. However, when doing this it opens a vim similar editor that can be difficult for those not familiar with the vim to utilize. If yous type this command printing "i" to enter insert mode and blazon the notes for the commit on the first line, press Esc, and then blazon ":wq" to salve, exit, and commit. Nosotros propose using the in a higher place command because it's easier for more people to use.

  1. Finally, at present that changes are moved from your workspace into your local repository information technology'south set to be pushed to the remote repository. Type the following command to push all changes to the remote repository.

Tip

If you lot want to follow the progress, yous can type git status again to see the current status. Y'all tin can also type git log to see a log of changes.

git push

Note

You'll be asked for your GitHub username and password if your figurer has not logged in to Git from the control line.

Once the file is pushed, it appears in your GitHub remote repository and is bachelor to everyone else who're working with the same repository.

Modifying a file and pushing to remote repository

  1. Edit and modify one or more files in your Git.
  2. Type git condition to see the condition of all the files not yet committed from the workspace to the local repository.
  3. Type the following control to add all files. The single catamenia indicates that you want all files to be added to the local repository. Some people may also use git add together -A to add all.

Tip

Yous tin can also use wildcards instead of a period. For instance, if you wanted to add all text files you could blazon *.txt instead of a single menses to merely add text files.

git add .
  1. Once the files are added, type the post-obit control to commit. Change the notes to apply to your commit.
git commit -m "Second update"
  1. Finally, type git push to push the commit to the remote repository.

Tip

If you're working with a lot of other people, nosotros'd recommend you pull (explained beneath) before committing. If your local repository is not the aforementioned as the remote repository (excluding your new changes), the commit fails. For example, if someone has added new files to the remote repository while you've been working and y'all endeavour commit, it fails until you pull.

Pulling or fetching updates from the remote repository

If it's been awhile since you've committed any piece of work, perform the git pull command to get the latest updates from the remote repository and merge them into your local repository. By pulling updates from a repository before committing, it verifies your local repository and the remote repository are the aforementioned and prevents merge conflicts.

To get all changes without merging, run the git fetch command to grab all of the latest updates from the remote repository without merging changes.

How to deal with a Git merge disharmonize

When multiple people are working with the same files, you're going to come across merge conflicts. When a conflict occurs, Git modifies your local files and it is up to you to manually prepare the files with the conflicts.

Tip

Use the git status command to encounter the status and merge conflict information.

Open up the file with the conflict to start correcting the errors. In the case file beneath, we had a text file with ane line of text and in the local repository we added the text "update1" to the file. However, during the same time, the remote repository file was modified and added "update2" to the file on the same line. Git marks conflicts with "<<<<<<< Head" for lines in the current branch and everything later on "=======" as the remote changes followed by ">>>>>>> < hash >" to mark the end.

Another file that is uploaded in-between pulls. <<<<<<< HEAD update1 ======= update2 >>>>>>> 62ee0eeba2e5b94d10574c1a6a68216e9b392e4c

To resolve this merge conflict, we would demand to decide what text nosotros wanted to keep, update, or remove. In this example, nosotros want to keep "update1" and "update2" in the social club they're listed and so we would only need to remove the Git markings to brand the file resemble the following example.

Some other file that is uploaded in-between pulls. update1 update2

Note

If you're working with a big file, it's a good idea to search the file for "Caput" because there may be more than ane conflict.

In one case the changes are made in the file, we could salve the file and then perform the following git commands to update the fixes.

git add .
git commit -m "Stock-still the merge disharmonize"
git push origin main

The case given in this merge conflict is a very basic example. When dealing with a file with more than a few lines of text or big sections of lawmaking, merge conflict can go a lot more confusing. To brand it easier to deal with merge conflicts, you can use the command git mergetool to use a merge tool, such as WinMerge or another popular merge tool.

Creating a Git branch

Creating a co-operative allows you to create a duplicate of the principal (trunk) and make several updates without affecting the master. For example, when developing a programme if a big fix was need that could accept weeks or months, a branch could be created for that fix. In one case you lot've fixed the bug, yous could merge your branch back into the master.

To create a branch in your local repository, follow the steps beneath.

  1. In the Git principal directory, type the post-obit command, where "<New Co-operative>" is the proper name of the new co-operative name. For example, we could call the branch "examplebranch".
git branch <New Co-operative>
  1. Next, blazon the following command to switch to the branch.
git checkout <Branch Name>
  1. After entering the higher up command, the prompt (in Git Fustigate) changes from "master" to the branch proper name to indicate you're working in a branch.
  2. From this point, you can go along to employ Git and modify the files how you have in the past.
  3. To see all available branches, yous tin can employ the git branch control. For example, typing git branch displays your local repository branches. Typing git co-operative -a displays all local and remote repositories.
  4. If you need to push the branch to the remote repository, you lot can run the following command.
git push --set up-upstream origin <Branch Name>
  1. Finally, if you lot need to switch back to the master branch, y'all can type the post-obit command.
git checkout primary

How to merge a branch dorsum into the master

After completing your piece of work, yous'll want to merge information technology back into the master or some other branch past following the steps below.

  1. Move into the branch you desire to merge into. For example, if you wanted to merge back into the master, type the post-obit command.
git checkout master
  1. Once in the master, type the post-obit control to merge the branch.
git merge <Co-operative Name>
  1. Once the merge is performed, add the files.
  2. Next, commit the changes.
  3. Once merged and committed, push the merge by typing the following command. If yous get conflicts during the merge, see our how to deal with merge conflicts section.
git button

How to delete a local and remote branch

If, subsequently merging a branch you no longer desire to keep the local or remote co-operative, you can perform the following commands.

To delete the local branch, type the following command.

git branch -d <Branch Name>

To delete the remote branch, type the following control.

git push button origin --delete <Branch Name>

Source: https://www.computerhope.com/issues/ch001927.htm

Posted by: coolidgetherintord.blogspot.com

0 Response to "How To Run Git Clone Command On Windows"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel