how to check diff after adding before committing
addした後,commit前に差分を確認する方法
git diff --cached filename
or
git diff --cached .
git reset HEAD filename
git fetch
git reset --hard origin/branch_name
# example
git fetch
git reset --hard origin/master
how to check diff before pull.
After doing a git fetch, do a git log HEAD..origin/master
to show the log entries between your last common commit and the origin's master branch.
To show the diffs, use either git log -p HEAD..origin/master
to show each patch,
or git diff HEAD...origin/master
(three dots not two) to show a single diff.
git fetch
git diff HEAD remote_name/branch_name # to show diff between local and remote
git log -p HEAD..remote_name/branch_name # to show log
git log HEAD...remote__name/branch_name # to show a single diff
# example
git fetch
git diff HEAD origin/master
git diff HEAD^
git diff remote_name/branch_name HEAD
# example
git diff origin/master HEAD
git commit --amend -m "commit message"
# example
git commit --amend -m "change commit message"
If you want change last commit message, then you can do
# Change commit message
git commit --amend
or
git commit --amend -m "new message"
# Push it
git push --force-with-lease <repository> <branch>
# example
git commit --amend -m "change commit message"
git push --force-with-lease origin master
If the repository you want change commit message is not used by only you, you have to care about force push.
See reference Stack Overflow.
I don't know if it works because I haven't try it...
git archive --remote=ssh://host/pathto/repo.git HEAD README.md
Just use curl or wget from Raw code page.
curl https://raw.githubusercontent.com/pytorch/examples/master/vae/main.py
下記のコマンドで履歴のないブランチを作成する。
git checkout --orphan empty-branch
ファイルを削除して、
git rm -rf .
コミットして、
git commit --allow-empty -m "root commit"
push。
git push origin empty-branch
ssh-keygen -t rsa -b 4096 -C "[email protected]"
git config --local user.name "username"
git config --local user.email "[email protected]"