git 常用指令

git update-git-for-windows Creating a new repository on the command line

git init
git add README.md
git commit -m "first commit"
git remote add origin http://github.com/userid/xxx.git
git push -u origin master

Pushing an existing repository from the command line

git remote add origin http://github.com/userid/xxx.git
git push -u origin master

利用Rstudio 的時候,常用的三個指令

git init .
git config user.name "myname"
git config user.email "myemail"

密碼問題

舊版直接打通關❌ 🏷

```bash?preclass=.w-75
git push https://userid:password@github.com/userid/repo.git 🏷
```

新版測試

😒只在電腦教室

參考這裡

  1. 先確定是在git repo目錄下
  2. cd .git
  3. notepad config,可能出現的內容
    [core]
      repositoryformatversion = 0
      filemode = false
      bare = false
      logallrefupdates = true
      symlinks = false
      ignorecase = true
    [remote "origin"]
      url = https://github.com/帳號/homework.git 🤸
      fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "main"]
      remote = origin
      merge = refs/heads/main
    
    
  4. 上面的url = https://github.com/帳號/homework.git改成
    [core]
      repositoryformatversion = 0
      filemode = false
      bare = false
      logallrefupdates = true
      symlinks = false
      ignorecase = true
    [remote "origin"]
      url = git@github.com:帳號/homework.git ✔️
      fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "main"]
      remote = origin
      merge = refs/heads/main
    
    

參考這裡 拿到 token 然後

git push https://userid:token@github.com/userid/repo.git 

更新.gitignore以後

```bash?preclass=.w-75
git rm -r --cached . 
git add . 
```

✔新版github的設定

git config user.name "xx"
git config user.email "xx@xx.com"
git remote set-url origin https://{金鑰}@github.com/{使用者ID}/blogR.git #🏷
git add .
git commit -m "更新原因" || true
git push
graph TD A[Working area] -->|git add .| B(staging) B -->|git commit -m message| C[local repo] C -->|git push| D[remote repo at github] D -->|git pull| A