GitHub - IUHEPandML/DataAnalysis GitHub Wiki

Setting Up Git and GitHub

Configure Git with Your GitHub Credentials

First, introduce your email and username to your GitHub account by running:

git config --global user.name "YOUR_USERNAME"
git config --global user.email "YOUR_EMAIL"

Create a New Repository on GitHub

  1. Create a new repository from the GitHub web page of your account.

Set Up SSH Keys

To authorize GitHub, it is recommended that you set up SSH keys on your PC and add them to your GitHub account.

ssh-keygen -t ed25519 -C "YOUR_EMAIL"

To connect to host github.com the following is usually used

If you had some issues or timeout errors it is may be due to the related wifi connection try to change the wifi connection, if still or no other internet source available try the following commands:

Please see the SSH keys subtitle below for instructions.

Initialize a New Repository Locally and Push to GitHub

After setting up your SSH key as explained, follow the steps below to commit the changes and push them to GitHub:

To Create a New Repository on the Command Line

echo "# test3" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin [email protected]:USERNAME/YOURREPONAME.git
git push -u origin main
  1. echo "# test3" >> README.md: Creates a README.md file with the text "# test3". This is typically done to initialize the repository with a readme file.
  2. git init: Initializes a new Git repository in the current directory. This creates a .git folder to track all changes.
  3. git add README.md: Adds the README.md file to the staging area.
  4. git commit -m "first commit": Commits the changes in the staging area with a message "first commit".
  5. git branch -M main: Renames the current branch to main.
  6. git remote add origin [email protected]:USERNAME/YOURREPONAME.git: Adds a remote repository called origin pointing to your GitHub repository.
  7. git push -u origin main: Pushes the changes to the main branch of the remote repository and sets the upstream tracking for the main branch.

To Push an Existing Repository from the Command Line

git remote add origin [email protected]:USERNAME/YOURREPONAME.git
git branch -M main
git push -u origin main
  1. git remote add origin [email protected]:USERNAME/YOURREPONAME.git: Adds a remote repository called origin pointing to your GitHub repository.
  2. git branch -M main: Renames the current branch to main.
  3. git push -u origin main: Pushes the changes to the main branch of the remote repository and sets the upstream tracking for the main branch.

Replace the placeholders written in capital letters:

  • Replace USERNAME with your GitHub username.
  • Replace YOURREPONAME with your repository name.

SSH Keys

  1. Generate an SSH key and add it to the SSH client. Refer to the link: Generate SSH Key and Add to SSH Client.

  2. Add the generated SSH key to your GitHub account. Refer to the link: Add SSH Key to GitHub Account.

  3. Test your SSH connection with GitHub by following the link: Test SSH Connection.

Also See


Essential Git Commands

⚠️ **GitHub.com Fallback** ⚠️