Чтобы создать запрос на включение в интерактивном режиме с помощью GitHub CLI (интерфейс командной строки), вы можете использовать несколько методов. Вот три распространенных подхода с примерами кода:
Метод 1: использование команды hub(GitHub CLI v1)
# Install the 'hub' tool (if not already installed)
$ brew install hub
# Create a new branch and switch to it
$ git checkout -b my-feature-branch
# Make your changes and commit them
$ git add .
$ git commit -m "Implement new feature"
# Push the branch to your remote repository
$ git push origin my-feature-branch
# Create a pull request interactively
$ hub pull-request
Метод 2: использование команды gh(GitHub CLI v2)
# Install the 'gh' tool (if not already installed)
$ brew install gh
# Authenticate with GitHub
$ gh auth login
# Create a new branch and switch to it
$ git checkout -b my-feature-branch
# Make your changes and commit them
$ git add .
$ git commit -m "Implement new feature"
# Push the branch to your remote repository
$ git push origin my-feature-branch
# Create a pull request interactively
$ gh pr create
Метод 3. Использование REST API GitHub (с cURL)
# Set the necessary variables
$ GITHUB_USER="your-username"
$ GITHUB_REPO="your-repository"
$ GITHUB_TOKEN="your-personal-access-token"
# Create a new branch and switch to it
$ git checkout -b my-feature-branch
# Make your changes and commit them
$ git add .
$ git commit -m "Implement new feature"
# Push the branch to your remote repository
$ git push origin my-feature-branch
# Create a pull request interactively using the GitHub REST API
$ curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-d '{
"title": "My Pull Request",
"head": "my-feature-branch",
"base": "main"
}' \
"https://api.github.com/repos/$GITHUB_USER/$GITHUB_REPO/pulls"