1
0
mirror of synced 2025-12-21 10:57:10 -05:00

ran script/content-migrations/remove-map-topics.js && script/content-migrations/update-tocs.js

This commit is contained in:
Sarah Schneider
2021-05-19 10:12:38 -04:00
parent 253c356fb0
commit f7e848e0c4
14528 changed files with 410545 additions and 411354 deletions

View File

@@ -0,0 +1,96 @@
---
title: About remote repositories
redirect_from:
- /articles/working-when-github-goes-down/
- /articles/sharing-repositories-without-github/
- /articles/about-remote-repositories
- /articles/which-url-should-i-use/
- /articles/which-remote-url-should-i-use
- /github/using-git/which-remote-url-should-i-use
- /github/using-git/about-remote-repositories
- /github/getting-started-with-github/about-remote-repositories
intro: 'GitHub''s collaborative approach to development depends on publishing commits from your local repository to {% data variables.product.product_name %} for other people to view, fetch, and update.'
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
### About remote repositories
A remote URL is Git's fancy way of saying "the place where your code is stored." That URL could be your repository on GitHub, or another user's fork, or even on a completely different server.
You can only push to two types of URL addresses:
* An HTTPS URL like `https://{% data variables.command_line.backticks %}/user/repo.git`
* An SSH URL, like `git@{% data variables.command_line.backticks %}:user/repo.git`
Git associates a remote URL with a name, and your default remote is usually called `origin`.
### Creating remote repositories
You can use the `git remote add` command to match a remote URL with a name.
For example, you'd type the following in the command line:
```shell
git remote add origin <em> &lt;REMOTE_URL> </em>
```
This associates the name `origin` with the `REMOTE_URL`.
You can use the command `git remote set-url` to [change a remote's URL](/github/getting-started-with-github/managing-remote-repositories).
### Choosing a URL for your remote repository
There are several ways to clone repositories available on {% data variables.product.product_location %}.
When you view a repository while signed in to your account, the URLs you can use to clone the project onto your computer are available below the repository details.
For information on setting or changing your remote URL, see "[Managing remote repositories](/github/getting-started-with-github/managing-remote-repositories)."
### Cloning with HTTPS URLs
The `https://` clone URLs are available on all repositories, regardless of visibility. `https://` clone URLs work even if you are behind a firewall or proxy.
When you `git clone`, `git fetch`, `git pull`, or `git push` to a remote repository using HTTPS URLs on the command line, Git will ask for your {% data variables.product.product_name %} username and password. {% data reusables.user_settings.password-authentication-deprecation %}
{% data reusables.command_line.provide-an-access-token %}
{% tip %}
**Tips**:
- You can use a credential helper so Git will remember your {% data variables.product.prodname_dotcom %} credentials every time it talks to {% data variables.product.prodname_dotcom %}. For more information, see "[Caching your {% data variables.product.prodname_dotcom %} credentials in Git](/github/getting-started-with-github/caching-your-github-credentials-in-git)."
- To clone a repository without authenticating to {% data variables.product.product_name %} on the command line, you can use {% data variables.product.prodname_desktop %} to clone instead. For more information, see "[Cloning a repository from {% data variables.product.prodname_dotcom %} to {% data variables.product.prodname_dotcom %} Desktop](/desktop/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop)."
{% endtip %}
{% if currentVersion == "free-pro-team@latest" %}If you'd rather use SSH but cannot connect over port 22, you might be able to use SSH over the HTTPS port. For more information, see "[Using SSH over the HTTPS port](/github/authenticating-to-github/using-ssh-over-the-https-port)."{% endif %}
### Cloning with SSH URLs
SSH URLs provide access to a Git repository via SSH, a secure protocol. To use these URLs, you must generate an SSH keypair on your computer and add the **public** key to your {% data variables.product.product_name %} account. For more information, see "[Connecting to {% data variables.product.prodname_dotcom %} with SSH](/github/authenticating-to-github/connecting-to-github-with-ssh)."
When you `git clone`, `git fetch`, `git pull`, or `git push` to a remote repository using SSH URLs, you'll be prompted for a password and must provide your SSH key passphrase. For more information, see "[Working with SSH key passphrases](/github/authenticating-to-github/working-with-ssh-key-passphrases)."
{% if currentVersion == "free-pro-team@latest" %}If you are accessing an organization that uses SAML single sign-on (SSO), you must authorize your SSH key to access the organization before you authenticate. For more information, see "[About authentication with SAML single sign-on](/github/authenticating-to-github/about-authentication-with-saml-single-sign-on)" and "[Authorizing an SSH key for use with SAML single sign-on](/github/authenticating-to-github/authorizing-an-ssh-key-for-use-with-saml-single-sign-on)."{% endif %}
{% tip %}
**Tip**: You can use an SSH URL to clone a repository to your computer, or as a secure way of deploying your code to production servers. You can also use SSH agent forwarding with your deploy script to avoid managing keys on the server. For more information, see "[Using SSH Agent Forwarding](/developers/overview/using-ssh-agent-forwarding)."
{% endtip %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.19" or currentVersion == "github-ae@latest" %}
### Cloning with {% data variables.product.prodname_cli %}
You can also install {% data variables.product.prodname_cli %} to use {% data variables.product.product_name %} workflows in your terminal. For more information, the [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) documentation.
{% endif %}
{% if currentVersion != "github-ae@latest" %}
### Cloning with Subversion
You can also use a [Subversion](https://subversion.apache.org/) client to access any repository on {% data variables.product.prodname_dotcom %}. Subversion offers a different feature set than Git. For more information, see "[What are the differences between Subversion and Git?](/github/importing-your-projects-to-github/what-are-the-differences-between-subversion-and-git)"
You can also access repositories on {% data variables.product.prodname_dotcom %} from Subversion clients. For more information, see "[Support for Subversion clients](/github/importing-your-projects-to-github/support-for-subversion-clients)."
{% endif %}

View File

@@ -0,0 +1,123 @@
---
title: Associating text editors with Git
intro: Use a text editor to open and edit your files with Git.
redirect_from:
- /textmate/
- /articles/using-textmate-as-your-default-editor/
- /articles/using-sublime-text-2-as-your-default-editor/
- /articles/associating-text-editors-with-git
- /github/using-git/associating-text-editors-with-git
- /github/getting-started-with-github/associating-text-editors-with-git
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
{% mac %}
### Using Atom as your editor
1. Install [Atom](https://atom.io/). For more information, see "[Installing Atom](https://flight-manual.atom.io/getting-started/sections/installing-atom/)" in the Atom documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "atom --wait"
```
### Using Visual Studio Code as your editor
1. Install [Visual Studio Code](https://code.visualstudio.com/) (VS Code). For more information, see "[Setting up Visual Studio Code](https://code.visualstudio.com/Docs/setup/setup-overview)" in the VS Code documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "code --wait"
```
### Using Sublime Text as your editor
1. Install [Sublime Text](https://www.sublimetext.com/). For more information, see "[Installation](https://docs.sublimetext.io/guide/getting-started/installation.html)" in the Sublime Text documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "subl -n -w"
```
### Using TextMate as your editor
1. Install [TextMate](https://macromates.com/).
2. Install TextMate's `mate` shell utility. For more information, see "[mate and rmate](https://macromates.com/blog/2011/mate-and-rmate/)" in the TextMate documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
4. Type this command:
```shell
$ git config --global core.editor "mate -w"
```
{% endmac %}
{% windows %}
### Using Atom as your editor
1. Install [Atom](https://atom.io/). For more information, see "[Installing Atom](https://flight-manual.atom.io/getting-started/sections/installing-atom/)" in the Atom documentation.
3. Type this command:
```shell
$ git config --global core.editor "atom --wait"
```
### Using Visual Studio Code as your editor
1. Install [Visual Studio Code](https://code.visualstudio.com/) (VS Code). For more information, see "[Setting up Visual Studio Code](https://code.visualstudio.com/Docs/setup/setup-overview)" in the VS Code documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "code --wait"
```
### Using Sublime Text as your editor
1. Install [Sublime Text](https://www.sublimetext.com/). For more information, see "[Installation](https://docs.sublimetext.io/guide/getting-started/installation.html)" in the Sublime Text documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "'C:/Program Files (x86)/sublime text 3/subl.exe' -w"
```
### Using Notepad++ as your editor
1. Install Notepad++ from https://notepad-plus-plus.org/. For more information, see "[Getting started](https://npp-user-manual.org/docs/getting-started/)" in the Notepad++ documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
```
{% endwindows %}
{% linux %}
### Using Atom as your editor
1. Install [Atom](https://atom.io/). For more information, see "[Installing Atom](https://flight-manual.atom.io/getting-started/sections/installing-atom/)" in the Atom documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "atom --wait"
```
### Using Visual Studio Code as your editor
1. Install [Visual Studio Code](https://code.visualstudio.com/) (VS Code). For more information, see "[Setting up Visual Studio Code](https://code.visualstudio.com/Docs/setup/setup-overview)" in the VS Code documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "code --wait"
```
### Using Sublime Text as your editor
1. Install [Sublime Text](https://www.sublimetext.com/). For more information, see "[Installation](https://docs.sublimetext.io/guide/getting-started/installation.html)" in the Sublime Text documentation.
{% data reusables.command_line.open_the_multi_os_terminal %}
3. Type this command:
```shell
$ git config --global core.editor "subl -n -w"
```
{% endlinux %}

View File

@@ -0,0 +1,103 @@
---
title: Caching your GitHub credentials in Git
redirect_from:
- /firewalls-and-proxies/
- /articles/caching-your-github-password-in-git
- /github/using-git/caching-your-github-password-in-git
- /github/using-git/caching-your-github-credentials-in-git
- /github/getting-started-with-github/caching-your-github-credentials-in-git
intro: 'If you''re [cloning {% data variables.product.product_name %} repositories using HTTPS](/github/getting-started-with-github/about-remote-repositories), you can use a credential helper to tell Git to remember your credentials.'
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
If you clone {% data variables.product.product_name %} repositories using SSH, then you authenticate using an SSH key instead of using other credentials. For information about setting up an SSH connection, see "[Generating an SSH Key](/articles/generating-an-ssh-key)."
{% mac %}
{% tip %}
**Tips:**
- You need Git **1.7.10** or newer to use the osxkeychain credential helper.
- If you installed Git using [Homebrew](http://brew.sh/), the `osxkeychain helper` will already be installed.
- If you're running Mac OS X 10.7 and above and you installed Git through Apple's Xcode Command Line Tools, then `osxkeychain helper` is automatically included in your Git installation.
{% endtip %}
Install Git and the `osxkeychain helper` and tell Git to use it.
1. Find out if Git and the `osxkeychain helper` are already installed:
```shell
$ git credential-osxkeychain
# Test for the cred helper
> Usage: git credential-osxkeychain &lt;get|store|erase>
```
2. If the `osxkeychain helper` isn't installed and you're running OS X version 10.9 or above, your computer will prompt you to download it as a part of the Xcode Command Line Tools:
```shell
$ git credential-osxkeychain
> xcode-select: note: no developer tools were found at '/Applications/Xcode.app',
> requesting install. Choose an option in the dialog to download the command line developer tools.
```
Alternatively, you can install Git and the `osxkeychain helper` by using [Homebrew](http://brew.sh/):
```shell
$ brew install git
```
4. Tell Git to use `osxkeychain helper` using the global `credential.helper` config:
```shell
$ git config --global credential.helper osxkeychain
# Set git to use the osxkeychain credential helper
```
The next time you clone an HTTPS URL that requires authentication, Git will prompt you for your username and password. {% data reusables.user_settings.password-authentication-deprecation %}
Once you've authenticated successfully, your credentials are stored in the macOS keychain and will be used every time you clone an HTTPS URL. You won't be required to type your credentials in to Git again unless you change your credentials.
{% endmac %}
{% windows %}
{% tip %}
**Tip:** You need Git **1.7.10** or newer to use the credential helper.
{% endtip %}
You can also install a native Git shell, such as [Git for Windows](https://git-for-windows.github.io/). With Git for Windows, running the following in the command line will store your credentials:
```shell
$ git config --global credential.helper wincred
```
{% endwindows %}
{% linux %}
{% tip %}
**Tip:** You need Git **1.7.10** or newer to use the credential helper.
{% endtip %}
Turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.
1. In Terminal, enter the following:
```shell
$ git config --global credential.helper cache
# Set git to use the credential memory cache
```
2. To change the default password cache timeout, enter the following:
```shell
$ git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
```
{% endlinux %}
### Further reading
- "[Updating credentials from the OSX Keychain](/articles/updating-credentials-from-the-osx-keychain/)"
- "[Creating a personal access token](/github/authenticating-to-github/creating-a-personal-access-token)"

View File

@@ -0,0 +1,131 @@
---
title: Configuring Git to handle line endings
intro: 'To avoid problems in your diffs, you can configure Git to properly handle line endings.'
redirect_from:
- /dealing-with-lineendings/
- /line-endings/
- /articles/dealing-with-line-endings/
- /articles/configuring-git-to-handle-line-endings
- /github/using-git/configuring-git-to-handle-line-endings
- /github/getting-started-with-github/configuring-git-to-handle-line-endings
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
Every time you press <kbd>return</kbd> on your keyboard you insert an invisible character called a line ending. Different operating systems handle line endings differently.
When you're collaborating on projects with Git and {% data variables.product.product_name %}, Git might produce unexpected results if, for example, you're working on a Windows machine, and your collaborator has made a change in macOS.
You can configure Git to handle line endings automatically so you can collaborate effectively with people who use different operating systems.
### Global settings for line endings
The `git config core.autocrlf` command is used to change how Git handles line endings. It takes a single argument.
{% mac %}
On macOS, you simply pass `input` to the configuration. For example:
```shell
$ git config --global core.autocrlf input
# Configure Git to ensure line endings in files you checkout are correct for macOS
```
{% endmac %}
{% windows %}
On Windows, you simply pass `true` to the configuration. For example:
```shell
$ git config --global core.autocrlf true
# Configure Git to ensure line endings in files you checkout are correct for Windows.
# For compatibility, line endings are converted to Unix style when you commit files.
```
{% endwindows %}
{% linux %}
On Linux, you simply pass `input` to the configuration. For example:
```shell
$ git config --global core.autocrlf input
# Configure Git to ensure line endings in files you checkout are correct for Linux
```
{% endlinux %}
### Per-repository settings
Optionally, you can configure a *.gitattributes* file to manage how Git reads line endings in a specific repository. When you commit this file to a repository, it overrides the `core.autocrlf` setting for all repository contributors. This ensures consistent behavior for all users, regardless of their Git settings and environment.
The *.gitattributes* file must be created in the root of the repository and committed like any other file.
A *.gitattributes* file looks like a table with two columns:
* On the left is the file name for Git to match.
* On the right is the line ending configuration that Git should use for those files.
#### Example
Here's an example *.gitattributes* file. You can use it as a template for your repositories:
```
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
```
You'll notice that files are matched—`*.c`, `*.sln`, `*.png`—, separated by a space, then given a setting—`text`, `text eol=crlf`, `binary`. We'll go over some possible settings below.
- `text=auto` Git will handle the files in whatever way it thinks is best. This is a good default option.
- `text eol=crlf` Git will always convert line endings to `CRLF` on checkout. You should use this for files that must keep `CRLF` endings, even on OSX or Linux.
- `text eol=lf` Git will always convert line endings to `LF` on checkout. You should use this for files that must keep LF endings, even on Windows.
- `binary` Git will understand that the files specified are not text, and it should not try to change them. The `binary` setting is also an alias for `-text -diff`.
### Refreshing a repository after changing line endings
When you set the `core.autocrlf` option or commit a *.gitattributes* file, you may find that Git reports changes to files that you have not modified. Git has changed line endings to match your new configuration.
To ensure that all the line endings in your repository match your new configuration, backup your files with Git, delete all files in your repository (except the `.git` directory), then restore the files all at once.
1. Save your current files in Git, so that none of your work is lost.
```shell
$ git add . -u
$ git commit -m "Saving files before refreshing line endings"
```
2. Add all your changed files back and normalize the line endings.
```shell
$ git add --renormalize .
```
3. Show the rewritten, normalized files.
```shell
$ git status
```
4. Commit the changes to your repository.
```shell
$ git commit -m "Normalize all the line endings"
```
### Further reading
- [Customizing Git - Git Attributes](https://git-scm.com/book/en/Customizing-Git-Git-Attributes) in the Pro Git book
- [git-config](https://git-scm.com/docs/git-config) in the man pages for Git
- [Getting Started - First-Time Git Setup](https://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup) in the Pro Git book
- [Mind the End of Your Line](http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/) by [Tim Clem](https://github.com/tclem)

View File

@@ -0,0 +1,14 @@
---
title: Git workflows
intro: '{% data variables.product.prodname_dotcom %} flow is a lightweight, branch-based workflow that supports teams and projects that deploy regularly.'
redirect_from:
- /articles/what-is-a-good-git-workflow/
- /articles/git-workflows
- /github/using-git/git-workflows
- /github/getting-started-with-github/git-workflows
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
You can adopt the {% data variables.product.prodname_dotcom %} flow method to standardize how your team functions and collaborates on {% data variables.product.prodname_dotcom %}. For more information, see "[{% data variables.product.prodname_dotcom %} flow](/github/getting-started-with-github/github-flow)."

View File

@@ -0,0 +1,62 @@
---
title: Ignoring files
redirect_from:
- /git-ignore/
- /ignore-files/
- /articles/ignoring-files
- /github/using-git/ignoring-files
- /github/getting-started-with-github/ignoring-files
intro: 'You can configure Git to ignore files you don''t want to check in to {% data variables.product.product_name %}.'
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
### Configuring ignored files for a single repository
You can create a *.gitignore* file in your repository's root directory to tell Git which files and directories to ignore when you make a commit.
To share the ignore rules with other users who clone the repository, commit the *.gitignore* file in to your repository.
GitHub maintains an official list of recommended *.gitignore* files for many popular operating systems, environments, and languages in the `github/gitignore` public repository. You can also use gitignore.io to create a *.gitignore* file for your operating system, programming language, or IDE. For more information, see "[github/gitignore](https://github.com/github/gitignore)" and the "[gitignore.io](https://www.gitignore.io/)" site.
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Navigate to the location of your Git repository.
3. Create a *.gitignore* file for your repository.
```shell
$ touch .gitignore
```
For an example *.gitignore* file, see "[Some common .gitignore configurations](https://gist.github.com/octocat/9257657)" in the Octocat repository.
If you want to ignore a file that is already checked in, you must untrack the file before you add a rule to ignore it. From your terminal, untrack the file.
```shell
$ git rm --cached <em>FILENAME</em>
```
### Configuring ignored files for all repositories on your computer
You can also create a global *.gitignore* file to define a list of rules for ignoring files in every Git repository on your computer. For example, you might create the file at *~/.gitignore_global* and add some rules to it.
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Configure Git to use the exclude file *~/.gitignore_global* for all Git repositories.
```shell
$ git config --global core.excludesfile ~/.gitignore_global
```
### Excluding local files without creating a *.gitignore* file
If you don't want to create a *.gitignore* file to share with others, you can create rules that are not committed with the repository. You can use this technique for locally-generated files that you don't expect other users to generate, such as files created by your editor.
Use your favorite text editor to open the file called *.git/info/exclude* within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Navigate to the location of your Git repository.
3. Using your favorite text editor, open the file *.git/info/exclude*.
### Further Reading
* [Ignoring files](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring) in the Pro Git book
* [.gitignore](https://git-scm.com/docs/gitignore) in the man pages for Git
* [A collection of useful *.gitignore* templates](https://github.com/github/gitignore) in the github/gitignore repository
* [gitignore.io](https://www.gitignore.io/) site

View File

@@ -0,0 +1,25 @@
---
title: Getting started with Git
intro: ''
redirect_from:
- /articles/getting-started-with-git-and-github
- /github/using-git/getting-started-with-git-and-github
- /github/using-git/learning-about-git
- /articles/learning-about-git
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
children:
- /setting-your-username-in-git
- /caching-your-github-credentials-in-git
- /why-is-git-always-asking-for-my-password
- /updating-credentials-from-the-macos-keychain
- /git-workflows
- /about-remote-repositories
- /managing-remote-repositories
- /associating-text-editors-with-git
- /configuring-git-to-handle-line-endings
- /ignoring-files
---

View File

@@ -0,0 +1,234 @@
---
title: Managing remote repositories
intro: 'Learn to work with your local repositories on your computer and remote repositories hosted on {% data variables.product.product_name %}.'
redirect_from:
- /categories/18/articles/
- /remotes/
- /categories/managing-remotes/
- /articles/managing-remote-repositories
- /articles/adding-a-remote
- /github/using-git/adding-a-remote
- /articles/changing-a-remote-s-url
- /articles/changing-a-remotes-url
- /github/using-git/changing-a-remotes-url
- /articles/renaming-a-remote
- /github/using-git/renaming-a-remote
- /articles/removing-a-remote
- /github/using-git/removing-a-remote
- /github/using-git/managing-remote-repositories
- /github/getting-started-with-github/managing-remote-repositories
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
### Adding a remote repository
To add a new remote, use the `git remote add` command on the terminal, in the directory your repository is stored at.
The `git remote add` command takes two arguments:
* A remote name, for example, `origin`
* A remote URL, for example, `https://{% data variables.command_line.backticks %}/user/repo.git`
For example:
```shell
$ git remote add origin https://{% data variables.command_line.codeblock %}/<em>user</em>/<em>repo</em>.git
# Set a new remote
$ git remote -v
# Verify new remote
> origin https://{% data variables.command_line.codeblock %}/<em>user</em>/<em>repo</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>user</em>/<em>repo</em>.git (push)
```
For more information on which URL to use, see "[About remote repositories](/github/getting-started-with-github/about-remote-repositories)."
#### Troubleshooting: Remote origin already exists
This error means you've tried to add a remote with a name that already exists in your local repository.
```shell
$ git remote add origin https://{% data variables.command_line.codeblock %}/octocat/Spoon-Knife.git
> fatal: remote origin already exists.
```
To fix this, you can:
* Use a different name for the new remote
* Rename the existing remote repository
* Delete the existing remote repository
### Changing a remote repository's URL
The `git remote set-url` command changes an existing remote repository URL.
{% tip %}
**Tip:** For information on the difference between HTTPS and SSH URLs, see "[About remote repositories](/github/getting-started-with-github/about-remote-repositories)."
{% endtip %}
The `git remote set-url` command takes two arguments:
* An existing remote name. For example, `origin` or `upstream` are two common choices.
* A new URL for the remote. For example:
* If you're updating to use HTTPS, your URL might look like:
```shell
https://{% data variables.command_line.backticks %}/<em>USERNAME</em>/<em>REPOSITORY</em>.git
```
* If you're updating to use SSH, your URL might look like:
```shell
git@{% data variables.command_line.codeblock %}:<em>USERNAME</em>/<em>REPOSITORY</em>.git
```
#### Switching remote URLs from SSH to HTTPS
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Change the current working directory to your local project.
3. List your existing remotes in order to get the name of the remote you want to change.
```shell
$ git remote -v
> origin git@{% data variables.command_line.codeblock %}:<em>USERNAME/REPOSITORY</em>.git (fetch)
> origin git@{% data variables.command_line.codeblock %}:<em>USERNAME/REPOSITORY</em>.git (push)
```
4. Change your remote's URL from SSH to HTTPS with the `git remote set-url` command.
```shell
$ git remote set-url origin https://{% data variables.command_line.codeblock %}/<em>USERNAME</em>/<em>REPOSITORY</em>.git
```
5. Verify that the remote URL has changed.
```shell
$ git remote -v
# Verify new remote URL
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY</em>.git (push)
```
The next time you `git fetch`, `git pull`, or `git push` to the remote repository, you'll be asked for your GitHub username and password. {% data reusables.user_settings.password-authentication-deprecation %}
You can [use a credential helper](/github/getting-started-with-github/caching-your-github-credentials-in-git) so Git will remember your GitHub username and personal access token every time it talks to GitHub.
#### Switching remote URLs from HTTPS to SSH
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Change the current working directory to your local project.
3. List your existing remotes in order to get the name of the remote you want to change.
```shell
$ git remote -v
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY</em>.git (push)
```
4. Change your remote's URL from HTTPS to SSH with the `git remote set-url` command.
```shell
$ git remote set-url origin git@{% data variables.command_line.codeblock %}:<em>USERNAME</em>/<em>REPOSITORY</em>.git
```
5. Verify that the remote URL has changed.
```shell
$ git remote -v
# Verify new remote URL
> origin git@{% data variables.command_line.codeblock %}:<em>USERNAME/REPOSITORY</em>.git (fetch)
> origin git@{% data variables.command_line.codeblock %}:<em>USERNAME/REPOSITORY</em>.git (push)
```
#### Troubleshooting: No such remote '[name]'
This error means that the remote you tried to change doesn't exist:
```shell
$ git remote set-url sofake https://{% data variables.command_line.codeblock %}/octocat/Spoon-Knife
> fatal: No such remote 'sofake'
```
Check that you've correctly typed the remote name.
### Renaming a remote repository
Use the `git remote rename` command to rename an existing remote.
The `git remote rename` command takes two arguments:
* An existing remote name, for example, `origin`
* A new name for the remote, for example, `destination`
### Example
These examples assume you're [cloning using HTTPS](/github/getting-started-with-github/about-remote-repositories/#cloning-with-https-urls), which is recommended.
```shell
$ git remote -v
# View existing remotes
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER</em>/<em>REPOSITORY</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER</em>/<em>REPOSITORY</em>.git (push)
$ git remote rename origin destination
# Change remote name from 'origin' to 'destination'
$ git remote -v
# Verify remote's new name
> destination https://{% data variables.command_line.codeblock %}/<em>OWNER</em>/<em>REPOSITORY</em>.git (fetch)
> destination https://{% data variables.command_line.codeblock %}/<em>OWNER</em>/<em>REPOSITORY</em>.git (push)
```
#### Troubleshooting: Could not rename config section 'remote.[old name]' to 'remote.[new name]'
This error means that the remote you tried the old remote name you typed doesn't exist.
You can check which remotes currently exist with the `git remote -v` command:
```shell
$ git remote -v
# View existing remotes
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER</em>/<em>REPOSITORY</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER</em>/<em>REPOSITORY</em>.git (push)
```
#### Troubleshooting: Remote [new name] already exists
This error means that the remote name you want to use already exists. To solve this, either use a different remote name, or rename the original remote.
### Removing a remote repository
Use the `git remote rm` command to remove a remote URL from your repository.
The `git remote rm` command takes one argument:
* A remote name, for example, `destination`
### Example
These examples assume you're [cloning using HTTPS](/github/getting-started-with-github/about-remote-repositories/#cloning-with-https-urls), which is recommended.
```shell
$ git remote -v
# View current remotes
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER/REPOSITORY</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER/REPOSITORY</em>.git (push)
> destination https://{% data variables.command_line.codeblock %}/<em>FORKER/REPOSITORY</em>.git (fetch)
> destination https://{% data variables.command_line.codeblock %}/<em>FORKER/REPOSITORY</em>.git (push)
$ git remote rm destination
# Remove remote
$ git remote -v
# Verify it's gone
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER/REPOSITORY</em>.git (fetch)
> origin https://{% data variables.command_line.codeblock %}/<em>OWNER/REPOSITORY</em>.git (push)
```
{% warning %}
**Note**: `git remote rm` does not delete the remote repository from the server. It simply
removes the remote and its references from your local repository.
{% endwarning %}
#### Troubleshooting: Could not remove config section 'remote.[name]'
This error means that the remote you tried to delete doesn't exist:
```shell
$ git remote rm sofake
> error: Could not remove config section 'remote.sofake'
```
Check that you've correctly typed the remote name.
### Further reading
- "[Working with Remotes" from the _Pro Git_ book](https://git-scm.com/book/en/Git-Basics-Working-with-Remotes)

View File

@@ -0,0 +1,52 @@
---
title: Setting your username in Git
intro: 'Git uses a username to associate commits with an identity. The Git username is not the same as your {% data variables.product.product_name %} username.'
redirect_from:
- /articles/setting-your-username-in-git
- /github/using-git/setting-your-username-in-git
- /github/getting-started-with-github/setting-your-username-in-git
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
You can change the name that is associated with your Git commits using the `git config` command. The new name you set will be visible in any future commits you push to {% data variables.product.product_name %} from the command line. If you'd like to keep your real name private, you can use any text as your Git username.
Changing the name associated with your Git commits using `git config` will only affect future commits and will not change the name used for past commits.
### Setting your Git username for *every* repository on your computer
{% data reusables.command_line.open_the_multi_os_terminal %}
2. {% data reusables.user_settings.set_your_git_username %}
```shell
$ git config --global user.name "<em>Mona Lisa</em>"
```
3. {% data reusables.user_settings.confirm_git_username_correct %}
```shell
$ git config --global user.name
> Mona Lisa
```
### Setting your Git username for a single repository
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Change the current working directory to the local repository where you want to configure the name that is associated with your Git commits.
3. {% data reusables.user_settings.set_your_git_username %}
```shell
$ git config user.name "<em>Mona Lisa</em>"
```
3. {% data reusables.user_settings.confirm_git_username_correct %}
```shell
$ git config user.name
> Mona Lisa
```
### Further reading
- "[Setting your commit email address](/articles/setting-your-commit-email-address)"
- ["Git Configuration" from the _Pro Git_ book](https://git-scm.com/book/en/Customizing-Git-Git-Configuration)

View File

@@ -0,0 +1,39 @@
---
title: Updating credentials from the macOS Keychain
intro: 'You''ll need to update your saved credentials in the `git-credential-osxkeychain` helper if you change your{% if currentVersion != "github-ae@latest" %} username, password, or{% endif %} personal access token on {% data variables.product.product_name %}.'
redirect_from:
- /articles/updating-credentials-from-the-osx-keychain
- /github/using-git/updating-credentials-from-the-osx-keychain
- /github/using-git/updating-credentials-from-the-macos-keychain
- /github/getting-started-with-github/updating-credentials-from-the-macos-keychain
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
{% data reusables.user_settings.password-authentication-deprecation %}
### Updating your credentials via Keychain Access
1. Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type `Keychain access` then press the Enter key to launch the app.
![Spotlight Search bar](/assets/images/help/setup/keychain-access.png)
2. In Keychain Access, search for **{% data variables.command_line.backticks %}**.
3. Find the "internet password" entry for `{% data variables.command_line.backticks %}`.
4. Edit or delete the entry accordingly.
### Deleting your credentials via the command line
Through the command line, you can use the credential helper directly to erase the keychain entry.
```shell
$ git credential-osxkeychain erase
host={% data variables.command_line.codeblock %}
protocol=https
> <em>[Press Return]</em>
```
If it's successful, nothing will print out. To test that it works, try and clone a private repository from {% data variables.product.product_location %}. If you are prompted for a password, the keychain entry was deleted.
### Further reading
- "[Caching your {% data variables.product.prodname_dotcom %} credentials in Git](/github/getting-started-with-github/caching-your-github-credentials-in-git/)"

View File

@@ -0,0 +1,23 @@
---
title: Why is Git always asking for my password?
intro: 'If Git prompts you for a username and password every time you try to interact with GitHub, you''re probably using the HTTPS clone URL for your repository.'
redirect_from:
- /articles/why-is-git-always-asking-for-my-password
- /github/using-git/why-is-git-always-asking-for-my-password
- /github/getting-started-with-github/why-is-git-always-asking-for-my-password
versions:
free-pro-team: '*'
enterprise-server: '*'
github-ae: '*'
---
Using an HTTPS remote URL has some advantages compared with using SSH. It's easier to set up than SSH, and usually works through strict firewalls and proxies. However, it also prompts you to enter your {% data variables.product.product_name %} credentials every time you pull or push a repository.
{% data reusables.user_settings.password-authentication-deprecation %}
You can avoid being prompted for your password by configuring Git to [cache your credentials](/github/getting-started-with-github/caching-your-github-credentials-in-git) for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.
### Further reading
- "[About remote repositories](/github/getting-started-with-github/about-remote-repositories)."
- "[About authentication to {% data variables.product.prodname_dotcom %}](/github/authenticating-to-github/about-authentication-to-github)"
- "[Adding your SSH key to the ssh-agent](/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent)"