Skip to content

Latest commit

 

History

History
120 lines (72 loc) · 2.21 KB

File metadata and controls

120 lines (72 loc) · 2.21 KB

GitHub Notes

Add Exisiting Project to Git

First go to the working directory which you would like to sync with GitHub, initalize the local directory as a Git repository:

git init

then add the fields in your new local repository by

git add .

Commit the files that you have staged in your local repository:

git commmit -m "First commit"

Next, add

git branch -M main

add the URL for the remote repository where your local repostory will be pushed:

git remote add origin <remote repository URL>

The step of pushing files (changes) in your local reposityr to GitHub by:

git push -u origin main

or

git push origin master

If they does not work, we can use:

git push origin main --force

or

git push origin master --force

Remove .DS_Store files

To remove .DS_Store fiels from a Git repository, you can first remove exisiting fields from the repository:

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

then do

echo .DS_Store >> .gitignore

More details see this link.

Update Github Repo

git add .

Then do commit:

git commit -m "updated"

Check if the repo is connected to the directory:

git remote -v

Then do the push:

git push origin main --force

Personal Access Token

Note that since August 13 2021 you need to use a personal access token instead of passowrd authentication.

You can follow this link, or github account, Settings --> Developer setting --> Personal access tokens -- > Select "repo" and "delete repo" --> Generate new token

Use your email address and token as password to access to github.

Add in your MacOS, you can do (see more details here):

  1. go to KeyChain Access,
  2. Search for "GitHub",
  3. then when then result "github.com" pops up, change the account or password to your new account, and save.