Wednesday, September 15, 2021

git basics adding project to GitHub

git remote add origin https://github.com/author/project.git

git init // all files in working directory

git add . // add all files in working directory

git commit -m "Add existing project files to Git"

git reset --soft HEAD~1 // cancel 1 last commit

git reset HEAD . // cancel all commits

git rebase --abort

git remote -v

git checkout -b currentbranchname // exit current branch

Already on 'a'

git checkout -b anotherbranchname // switch to another branch

Switched to branch 'b'

git push origin branchname

git push -u -f origin branchname

-u switch makes the remote GitHub repo the default for your existing project

-f switch forces Git to overwrite any files that already exist on GitHub

error: Your local changes to the following files would be overwritten by checkout:

git checkout -f branchname


git config -l

git config --edit

git config --global --edit

git init -b branch-name

git repo create project-name


git pull --set-upstream origin branch-name

git add . && git commit -m "initial commit" && git push

git push --force origin HEAD: branch-name


git status

git commit -m “Your message” {filename}

git status

git push origin branch-name

https://docs.github.com/en/github/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line

1. Verify your email address.

In the top right corner of any GitHub page, click on your profile photo and then on “Settings.”

2. Settings on GitHub page

3. In the left sidebar of the “Settings” page, click on “Developer settings.”

Developer settings

4. In the left sidebar of the “Developer settings” page, click on “Personal access tokens.”

Personal access tokens

5. Click on “Generate new token.”

Generating a new token

6. Give your token a name and select the scopes and permissions you would like to grant to it. Please note that if you want to use your token to access repositories from the command line, you have to select the “repo” option.

Scopes and permissions

7. Click on the “Generate token” button and then insert your password as requested by GitHub.

8. Copy the token to your clipboard and store it in a safe place. Keep in mind that after leaving this page, for security reasons, you will not be able to see the token again.

https://betterprogramming.pub/dealing-with-github-password-authentication-deprecation-1b59ced90065

If you prefer a little privacy, when you make commits in GitHub repositories, you have the option to keep your email private and use the default noreply email from GitHub. This is awesome.

To do this, go to you Settings , then Emails , select: Keep my email addresses private.

From there, you would have to remember to update your git config user.email to use your default noreply: <username>@users.noreply.github.com

If you happen to forget to update your commit email address, GitHub will prevent you from pushing your changes to remote repository. To fix this, you can amend your previous commits to update to the noreply email:

git commit --amend --reset-author

https://codelovingyogi.medium.com/using-githubs-noreply-email-address-48aa2a16ba42

No comments:

Post a Comment