4. Внесение изменений
Добавим кое-какие HTML-теги к нашему приветствию. Измените содержимое файла на:
Файл: hello.html
h1>Hello, World!h1>
02 Проверьте состояние
Теперь проверьте состояние рабочей директории.
Выполните
git status
Результат
$ git status On branch main Changes not staged for commit: (use "git add . " to update what will be committed) (use "git restore . " to discard changes in working directory) modified: hello.html no changes added to commit (use "git add" and/or "git commit -a")
Первое, что нужно заметить, это то, что Git знает, что файл hello.html был изменен, но при этом эти изменения еще не зафиксированы в репозитории.
Также обратите внимание на то, что сообщение о состоянии дает вам подсказку о том, что нужно делать дальше. Если вы хотите добавить эти изменения в репозиторий, используйте команду git add . В противном случае используйте команду git сheckout для отмены изменений.
Отправка изменений в GitHub из GitHub Desktop
As you commit changes to your project locally, you can push those changes to GitHub from GitHub Desktop so that others may access them from the remote repository.
Кто может использовать эту функцию.
People with write permissions can push changes to a repository.
Сведения об отправке изменений в GitHub
При отправке изменений зафиксированные изменения в локальном репозитории отправляются в удаленный репозиторий в GitHub. Если вы изменяете проект локально и хотите, чтобы другие пользователи имели доступ к изменениям, необходимо отправить изменения в GitHub.
Перед отправкой изменений необходимо обновить локальную ветвь, чтобы включить все фиксации, добавленные в удаленный репозиторий. Если кто-то выполнил фиксации на удаленном компьютере, который не включен в локальную ветвь, GitHub Desktop предложит получить новые фиксации перед отправкой изменений, чтобы избежать конфликтов при объединении. Дополнительные сведения см. в разделе «AUTOTITLE».
Администраторы репозитория могут включать защиты в ветви. Если вы работаете с защищенной ветвью, то не сможете удалить или принудительно отправить ее в ветвь. Администраторы репозитория могут включить другие параметры защищенной ветви для применения определенных рабочих процессов, прежде чем можно будет выполнить слияние для ветви. Дополнительные сведения см. в разделе «AUTOTITLE».
Администраторы репозитория также могут включить наборы правил для ветви, что позволит предотвратить выполнение принудительной отправки, если набор правил не был выполнен. Например, для набора правил может потребоваться определенное соглашение об именовании ветви или номер проблемы в начале сообщения фиксации. GitHub Desktop предупреждает о наборах правил, чтобы предотвратить переход ветви в состояние, в котором вы не сможете отправить изменения. Дополнительные сведения см. в разделе «AUTOTITLE».
Отправка изменений в GitHub
Примечание. GitHub Desktop отклоняет отправку, если она превышает определенные ограничения.
- Отправка содержит большой файл, размер которого превышает 100 МиБ.
- Общий размер отправки превышает 2 ГиБ.
Если настроить Хранилище больших файлов Git для отслеживания больших файлов, можно отправить большие файлы, которые в обычном случае были бы отклонены. Дополнительные сведения см. в разделе «AUTOTITLE».

- Чтобы отправить локальные изменения в удаленный репозиторий, в строке репозитория щелкните «Отправить источник«.

Дополнительные материалы
- «Глоссарий GitHub» в глоссарии GitHub
- «Фиксация и проверка изменений в проекте в GitHub Desktop»
- «С помощью Git»
Изменение файлов
Вы можете редактировать файлы непосредственно в GitHub в любом репозитории с помощью редактора файлов.
Editing files in your repository
Tip: If a repository has any protected branches, you can’t edit or upload files in the protected branch using GitHub. For more information, see «About protected branches.»
You can use GitHub Desktop to move your changes to a new branch and commit them. For more information, see «Committing and reviewing changes to your project in GitHub Desktop.»
Note: GitHub’s file editor uses CodeMirror.
- In your repository, browse to the file you want to edit.
- In the upper right corner of the file view, click

to open the file editor.
Note: Instead of editing and committing the file using the default file editor, you can optionally choose to use the github.dev code editor by selecting the

dropdown menu and clicking github.dev. You can also clone the repository and edit the file locally via GitHub Desktop by clicking GitHub Desktop.



Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is the default branch, you should choose to create a new branch for your commit and then create a pull request. For more information, see «Creating a pull request.»
Editing files in another user’s repository
When you edit a file in another user’s repository, we’ll automatically fork the repository and open a pull request for you.
- In another user’s repository, browse to the folder that contains the file you want to edit. Click the name of the file you want to edit.
- Above the file content, click

. At this point, GitHub forks the repository for you.

Получение изменений из удаленного репозитория
Для доступа к удаленным репозиториям можно использовать распространенные команды Git.
Options for getting changes
These commands are very useful when interacting with a remote repository. clone and fetch download remote code from a repository’s remote URL to your local computer, merge is used to merge different people’s work together with yours, and pull is a combination of fetch and merge .
Cloning a repository
To grab a complete copy of another user’s repository, use git clone like this:
$ git clone https://github.com/USERNAME/REPOSITORY.git # Clones a repository to your computer
You can choose from several different URLs when cloning a repository. While logged in to GitHub, these URLs are available on the main page of the repository when you click

When you run git clone , the following actions occur:
- A new folder called repo is made
- It is initialized as a Git repository
- A remote named origin is created, pointing to the URL you cloned from
- All of the repository’s files and commits are downloaded there
- The default branch is checked out
For every branch foo in the remote repository, a corresponding remote-tracking branch refs/remotes/origin/foo is created in your local repository. You can usually abbreviate such remote-tracking branch names to origin/foo .
Fetching changes from a remote repository
Use git fetch to retrieve new work done by other people. Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches.
If you already have a local repository with a remote URL set up for the desired project, you can grab all the new information by using git fetch *remotename* in the terminal:
$ git fetch REMOTE-NAME # Fetches updates made to a remote repository
Otherwise, you can always add a new remote and then fetch. For more information, see «Managing remote repositories.»
Merging changes into your local branch
Merging combines your local changes with changes made by others.
Typically, you’d merge a remote-tracking branch (i.e., a branch fetched from a remote repository) with your local branch:
$ git merge REMOTE-NAME/BRANCH-NAME # Merges updates made online with your local work
Pulling changes from a remote repository
git pull is a convenient shortcut for completing both git fetch and git merge in the same command:
$ git pull REMOTE-NAME BRANCH-NAME # Grabs online updates and merges them with your local work
Because pull performs a merge on the retrieved changes, you should ensure that your local work is committed before running the pull command. If you run into a merge conflict you cannot resolve, or if you decide to quit the merge, you can use git merge —abort to take the branch back to where it was in before you pulled.
Further reading
- «Working with Remotes» from the Pro Git book»
- «Troubleshooting connectivity problems»