{"id":18930563,"url":"https://github.com/techprimers/github-cli-example","last_synced_at":"2025-10-24T14:02:26.187Z","repository":{"id":85853594,"uuid":"299064547","full_name":"TechPrimers/github-cli-example","owner":"TechPrimers","description":"Github CLI Example repo","archived":false,"fork":false,"pushed_at":"2020-09-27T16:14:08.000Z","size":14,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-25T02:44:41.498Z","etag":null,"topics":["github","github-cli"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TechPrimers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-27T15:46:07.000Z","updated_at":"2022-09-23T11:21:05.000Z","dependencies_parsed_at":"2023-03-13T07:00:09.308Z","dependency_job_id":null,"html_url":"https://github.com/TechPrimers/github-cli-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TechPrimers/github-cli-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechPrimers%2Fgithub-cli-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechPrimers%2Fgithub-cli-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechPrimers%2Fgithub-cli-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechPrimers%2Fgithub-cli-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TechPrimers","download_url":"https://codeload.github.com/TechPrimers/github-cli-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechPrimers%2Fgithub-cli-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274815564,"owners_count":25355210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-cli"],"created_at":"2024-11-08T11:38:08.059Z","updated_at":"2025-10-24T14:02:26.093Z","avatar_url":"https://github.com/TechPrimers.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Github CLI Example\n \n## Installation\n- CLI can be installed using the steps mentioned in [https://cli.github.com/](https://cli.github.com/)\n\n## Command used\n1. Authenticate the Github CLI `gh` with your github.com account using `gh auth login`\n```\n❯ gh auth login\n\n? What account do you want to log into? GitHub.com\n- Logging into github.com\n? You're already logged into github.com as MovingToWeb. Do you want to re-authenticate? Yes\n? How would you like to authenticate? Login with a web browser\n\n! First copy your one-time code: F960-6144\n- Press Enter to open github.com in your browser...\n✓ Authentication complete. Press Enter to continue...\n\n? Choose default git protocol HTTPS\n- gh config set -h github.com git_protocol https\n✓ Configured git protocol\n✓ Logged in as MovingToWeb\n```\n\n2. Create new repo using `gh repo create`. `TechPrimers/` denotes the organization under which the repository needs to be created.\n```\n❯ gh repo create TechPrimers/github-cli-example\n\n? Visibility Public\n? This will create 'TechPrimers/github-cli-example' in your current directory. Continue?  Yes\n✓ Created repository TechPrimers/github-cli-example on GitHub\n? Create a local project directory for TechPrimers/github-cli-example? Yes\nInitialized empty Git repository in /Users/ajay/Documents/code/github-cli-example/.git/\n✓ Initialized repository in './github-cli-example/'\n```\n\n3. Add a new file in the empty repo, commit it and push it to remote repository (github.com)\n\n```\n❯ cd github-cli-example\n\n❯ vi README.md\n\n❯ git add .\n\n❯ git commit -am \"[add] new file\"\n[main (root-commit) ccb0927] [add] new file\n 1 file changed, 1 insertion(+)\n create mode 100644 README.md\n\n❯ git push --set-upstream origin main\nUsername for 'https://github.com': MovingToWeb\nPassword for 'https://MovingToWeb@github.com':\nEnumerating objects: 3, done.\nCounting objects: 100% (3/3), done.\nWriting objects: 100% (3/3), 246 bytes | 246.00 KiB/s, done.\nTotal 3 (delta 0), reused 0 (delta 0), pack-reused 0\nTo https://github.com/TechPrimers/github-cli-example.git\n * [new branch]      main -\u003e main\nBranch 'main' set up to track remote branch 'main' from 'origin'.\n\n❯ gh repo view\n```\n\n4. Get documentation/help from the CLI directly using `--help` or `help` command\n```\n❯ gh config --help\n\nUsage:  gh config [flags]\n\nAvailable commands:\n  get\n  set\n\n❯ gh help\nWork seamlessly with GitHub from the command line.\n\nUSAGE\n  gh \u003ccommand\u003e \u003csubcommand\u003e [flags]\n\nCORE COMMANDS\n  gist:       Create gists\n  issue:      Manage issues\n  pr:         Manage pull requests\n  release:    Manage GitHub releases\n  repo:       Create, clone, fork, and view repositories\n\nADDITIONAL COMMANDS\n  alias:      Create command shortcuts\n  api:        Make an authenticated GitHub API request\n  auth:       Login, logout, and refresh your authentication\n  completion: Generate shell completion scripts\n  config:     Manage configuration for gh\n  help:       Help about any command\n\nFLAGS\n  --help      Show help for command\n  --version   Show gh version\n\nEXAMPLES\n  $ gh issue create\n  $ gh repo clone cli/cli\n  $ gh pr checkout 321\n\nENVIRONMENT VARIABLES\n  See 'gh help environment' for the list of supported environment variables.\n\nLEARN MORE\n  Use 'gh \u003ccommand\u003e \u003csubcommand\u003e --help' for more information about a command.\n  Read the manual at https://cli.github.com/manual\n\nFEEDBACK\n  Open an issue using 'gh issue create -R cli/cli'\n```\n\n5. Let's create a new issue to work on a new feature\n```\n❯ gh issue create\n\nCreating issue in TechPrimers/github-cli-example\n\n? Title Create a new feature\n? Body \u003cReceived\u003e\n? What's next? Submit\nhttps://github.com/TechPrimers/github-cli-example/issues/1\n```\n\n6. Let's create a feature branch and add the implementation of the feature in it.\n```\n❯ git checkout -b feature-1\nSwitched to a new branch 'feature-1'\n\n❯ vi README.md\n\n❯ git commit -am \"[update] modified readme file\"\n[feature-1 f60a6c4] [update] modified readme file\n 1 file changed, 2 insertions(+)\n\n❯ git push --set-upstream origin feature-1\nEnumerating objects: 5, done.\nCounting objects: 100% (5/5), done.\nWriting objects: 100% (3/3), 307 bytes | 307.00 KiB/s, done.\nTotal 3 (delta 0), reused 0 (delta 0), pack-reused 0\nremote:\nremote: Create a pull request for 'feature-1' on GitHub by visiting:\nremote:      https://github.com/TechPrimers/github-cli-example/pull/new/feature-1\nremote:\nTo https://github.com/TechPrimers/github-cli-example.git\n * [new branch]      feature-1 -\u003e feature-1\nBranch 'feature-1' set up to track remote branch 'feature-1' from 'origin'.\n```\n\n7. To get the list of issue, use `list` command\n```\n❯ gh issue list\n```\n\n8. To create a pull request from the feature branch to the main branch, we can use `gh pr create`\n```\n❯ gh pr create\n\nCreating pull request for feature-1 into main in TechPrimers/github-cli-example\n\n? Title Added new Feature for issue-1\n? Body \u003cReceived\u003e\n? What's next? Submit\nhttps://github.com/TechPrimers/github-cli-example/pull/2\n```\n\n9. Use `list` to list the pull requests for the repo\n```\n❯ gh pr list\n```\n\n10. Finally merging the pull request can be done by `gh pr merge`\n```\n❯ gh pr merge\n\n? What merge method would you like to use? Create a merge commit\n? Delete the branch locally and on GitHub? Yes\n✔ Merged pull request #2 (Added new Feature for issue-1)\n✔ Deleted branch feature-1 and switched to branch main\n```\n\n## References\n- [Github manual](https://cli.github.com/manual/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechprimers%2Fgithub-cli-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechprimers%2Fgithub-cli-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechprimers%2Fgithub-cli-example/lists"}