to select ↑↓ to navigate
Developer References

Developer References

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

Using GitHub

Install GitHub CLI

$ curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null $ sudo apt update $ sudo apt install gh

Create a new repository on the command line

$ echo "# My Project" >> README.md $ git init $ git add README.md $ git commit -m "first commit" $ git branch -M main

$ git remote add origin git@github.com:User/Project.git #OR $ git remote add origin https://github.com/User/Project.git

$ git push -u origin main

Push an existing repository from the command line

$ git remote add origin git@github.com:User/Project.git #OR $ git remote add origin https://github.com/User/Project.git

$ git branch -M main $ git push -u origin main

Fix Author Identity

Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly:

git config --global user.name "Your Name" git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

Commands

"git add" command to stage changes for the next commit. The actual commit command will then wrap up the mentioned changes in a new commit object:

$ git add index.html css/styles.css $ git commit -m "Change titles and styling on homepage"

If you have lots of changed files in your working copy - and want all of them included in the next commit - you can make use of the "-a" parameter and thereby omit the "git add" step:

git commit -a -m "Change titles and styling on homepage"

The "--amend" option comes in handy, for example, when you mistyped the last commit's message or forgot to add a change. The following example will correct the very last commit by overwriting its message and adding another change:

git add forgotten-change.js git commit --amend -m "New commit message"

use "git add <file>..." to update what will be committed

use "git restore <file>..." to discard changes in working directory

use "git restore --staged <file>..." to unstage

Push to Remote Repository:

$ git push

Last updated 2 months ago
Was this helpful?
Thanks!