github

github

Github 本地上更新库

## Initialize your directory
git init

## 关联
git remote add IO https://github.com/Karobben/Karobben.github.io

##添加
git add .

##注释
git commit -m "注释"

git pull --rebase IO master
git push -u IO master

Avoid password everytime

Click me

when uploading file is to big

git config http.postBuffer 524288000

ignore files

Cite: Git-scm

the name of the file: .gitignore should keep in the home directory rather than the .git directory

$ cat .gitignore
# exclude everything except directory foo/bar
/*
!/foo
/foo/*
!/foo/bar
  • An optional prefix “!” which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded.
  • An asterisk “*” matches anything except a slash.
  • A trailing “/" matches everything inside. For example, "abc/” matches all files inside directory “abc”, relative to the location of the .gitignore file, with infinite depth.
  • A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, “a/**/b” matches “a/b”, “a/x/b”, “a/x/y/b” and so on.

Delete large files

© Daniel Andrei Mincă; 2015

$ git rm --cached giant_file
# Stage our giant file for removal, but leave it on disk

git commit --amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well

git push
# Push our rewritten, smaller commit

Another way to solve the same problem

© Clark McCauley; 2022

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' HEAD

Git push with ssh

Documentation: Github

Follow the instructions from Github to generate a ssh public key first.
Be sure about add the email for config the user

Exp:

ssh-keygen -t ed25519 -C "your_email@example.com"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519

After that, copy the key into github.

You may still find that Username is needed for push.
According 2240, we need to change the type or remote link.

Enter your github repository page and select the ssh link to configure the local repository as follow and the problem shell be solved.

git remote set-url origin git@github.com:username/repo.git

Re-base the Local by Deleting all Local Change

git stash
git pull

Reference: Cameron McKenzie

  • The git stash command, which saves uncommitted changes and reset your workspace.
  • The git reset command, which only touches tracked files.
  • The git clean command, that deletes every untracked file.

Errors

fatal: in unpopulated submodule ‘.deploy_git’

fatal: in unpopulated submodule '.deploy_git'
FATAL { err:
   { Error: Spawn failed
       at ChildProcess.task.on.code (/mnt/8A26661926660713/Github/Notes_BK/node_modules/hexo-util/lib/spawn.js:51:21)
       at ChildProcess.emit (events.js:198:13)
       at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) code: 128 } } 'Something\'s wrong. Maybe you can find the solution here: %s' '\u001b[4mhttps://hexo.io/docs/troubleshooting.html\u001b[24m'

According to ChatGPT (this is a super genius! I can’t find this result anywhere!) The error message you provided is related to Hexo, a static site generator. It seems that there was an issue with a submodule named ‘.deploy_git’ in the Git repository you were working with.

This error occurs when there’s a problem with the Git submodule in your Hexo project, and it’s not able to be cloned. To resolve this issue, try the following steps:

# Remove the problematic submodule:
git rm --cached .deploy_git
# Commit the changes:
git commit -m "Removed problematic submodule"
# Re-add the submodule:
# Replace <repo> with the URL of the Git repository for the submodule.
git submodule add -b master <repo> .deploy_git
# Initialize the submodule:
git submodule init
# Update the submodule:
git submodule update

These steps should resolve the issue with the Git submodule and allow you to continue using Hexo to generate your static site. If the issue persists, you may need to refer to the Hexo troubleshooting guide (https://hexo.io/docs/troubleshooting.html) for further assistance.

Author

Karobben

Posted on

2020-06-23

Updated on

2024-01-22

Licensed under

Comments