banner



How To Use Git On Windows 10 Command Line

Author avatar

Using Git (and GitHub) on Windows

Douglas Matoso

Summary

This guide volition bear witness how to install Git on Windows, create a local repository, and then button information technology to GitHub.

Installing Git

Execute the downloaded file. In the page Select Components you tin leave the options at their defaults.

The Windows Explorer integration > Context menu entries pick allows opening the Git command prompt (Git Fustigate) from any folder past clicking with the correct mouse button on the folder and selecting Git Bash Here. The last option is as well interesting in that it installs a better font for all console windows.

Note: Git for Windows comes with its ain command prompt (Git Bash) that, besides git commands, has some useful Unix commands (and it looks better than the Windows default prompt).

On the next screen (Adjusting your path environs), I cull the most conservative option: Use Git Bash only. This will make git commands bachelor merely in Git Bash and volition non alter your PATH variable. Click Next.

Another important setting: line endings. As you may know, Windows and Unix systems (Linux, Mac) have dissimilar formats of line breaks on text files. If you write a file with Windows line breaks, some other person may take problems opening that file in Linux and vice-versa. The line endings setting allows yous to normalize this.

I prefer choosing the second choice (Checkout every bit-is, commit Unix-fashion line endings), that won't modify the line breaks when the file arrives but volition convert them to Unix-style when yous commit. That way, you don't risk committing Windows-style line breaks and everything is kept in Unix-fashion. Don't worry, even though y'all are in Windows, most of the text editors can read Unix line breaks just fine.

After that one more Next, Finish, and Git is installed!

Creating a Local Repository

Permit'due south test information technology. Create a folder, correct-click, and choose Git Fustigate Here.

Earlier anything else, allow'southward inform Git who you are then that your commits can be identified. Enter the commands, replace the quoted data with your real name and e-post: (printing Enter after each one).

                                      1                    git                                          config --global user.proper noun                                        "Firstname Lastname"                                                            two                                        git                                          config --global user.electronic mail                                        "[e-mail protected]"                                  

fustigate

Now let's initialize a Git repository on this folder:

Run into that (principal) on the control line? It tells you the current co-operative y'all are in a Git repository. The primary branch is the main branch on every Git repo.

Now let's add a new file and commit it. Look at the control sequence (printing Enter after each ane):

                                      1                    touch on                                          exam.txt                                        2                                        git                                                            add                                                            .                                                            3                                        git                                          commit -1000                                        "Commencement commit"                                  

beat out

First, nosotros create an empty text file (you tin can create the file any fashion you like, not necessarily with the affect command). So nosotros add all new and modified files to the Git index (we tell Git which files we desire to commit on the next commit). And finally we commit the changes with a message.

Sharing Your Lawmaking on GitHub

Absurd! Y'all take a Git repo in your auto just how well-nigh sharing your code on GitHub?

Initial Setup

If yous don't have a GitHub account yet, go to http://github.com and create one. It's free.

After you signup and login, let's add an SSH key so GitHub can link your business relationship with this calculator. That way information technology won't have to enquire for your password on every commit.

On Git Bash enter the command:

Use the aforementioned email you registered at GitHub.

On the adjacent question, press Enter to cull the default value.

Now information technology will ask for a password. Enter a password (this is Non your GitHub password). When it asks for a confirmation, enter the password again. Now enter the command:

                                      1                    notepad ~/.ssh/id_rsa.pub                                  

bash

To open on Notepad the file that was created.

On GitHub, go to Settings and so SSH and GPG Keys. Click New SSH cardinal. Enter a title to identify this computer and in the field Key paste all the contents of the file id_rsa.pub.

Be conscientious to copy and paste all the contents of the file, beginning at "ssh-ras ..." up to your e-mail (including it). Click Add together SSH primal.

Let'south check if everything is ok. On Git Bash enter:

It will ask if you want to connect to a remote machine. Type yes and press Enter. Next, it will inquire for a password. Enter the password you used on the ssh-keygen control.

If you see a message like:

                                      1                    Hullo user! Y'all've successfully authenticated, just GitHub does not provide shell access.                                  

Then everything is correct!

Creating Your Commencement Remote Repository

On GitHub, let'south create a new repository (button New repository on your dashboard). Enter a name; it should not have spaces or special characters, every bit it volition exist role of the URL of your new repo. You can leave the residuum of the options at their defaults.

You will be taken to the primary folio of your repository, that doesn't have any files yet.

On Git Fustigate (on the binder of your local repository) enter:

Note that user/repo_name must be entered the same way they appear in your repository URL, like:

Now, to send your files to GitHub, enter:

                                      one                    git                                          push origin main                                  

bash

Inform the password of the SSH cardinal if it asks.

Reload the page of your repo on GitHub and you lot should run into your committed files.

Determination

Even though Git originated on Linux (did you know that it was created by Linus Torvalds, the same guy who created Linux?), developers on all system can benefit from it. Git is an excellent SCM (source code management) system, widely adopted, and the open-source community on GitHub is vibrant! You can find code for pretty much anything you want, contribute with other developers and share your own solutions.

Source: https://www.pluralsight.com/guides/using-git-and-github-on-windows

Posted by: bustostholdrie1970.blogspot.com

0 Response to "How To Use Git On Windows 10 Command Line"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel