Sync a fork of a repository to keep it up-to-date with the upstream repository.
- git fetch upstream
- git checkout master
- git merge upstream/master
- git push origin master
- git checkout home (home is a branch)
- git rebase master
- git push origin home
Sync branch:
git fetch --prune
Update a PR:
- git reset --hard (optional)
Did my changes in code I wanted to do - git add
- git commit --amend
- git push -f origin
git config --global credential.helper cache
ref: https://help.github.com/articles/caching-your-github-password-in-git/#platform-linux
Create a new branch:
git checkout -b office master
Count:
git rev-list --count HEAD --since="March 20 2020"
git rev-list --count HEAD --since="February 20 2020" --before="March 20 2020"
Create alias:
git config --global alias.co checkout
git config --global alias.st status
Move file to untracked file:
git rm welcome.html --cached
Finish and delete branch:
- git branch -D fcrepo-xxxx
- git push origin :fcrepo-xxxx
- Get the PR changes into the test branch:> git fetch origin pull/1485/head:test
- Create a test branch to merge the PR into locally. Assuming you're on the master branch:
> git checkout test
git remote set-url origin NEWURL
Show remote URI
git config --get remote.origin.url
Delete all commit history
- Checkout
git checkout --orphan latest_branch - Add all the files
git add -A - Commit the changes
git commit -am "commit message" - Delete the branch
git branch -D master - Rename the current branch to master
git branch -m master - Finally, force update your repository
git push -f origin master
- https://github.com/[user]/[repo]/watchers
- https://github.com/[user]/[repo]/stargazers
- git log --graph --all --format=format:'%h - (%ai) %s — %cn %d' --abbrev-commit --date=relative -1
Output: 6080b81 - (2017-11-14 21:41:39 +0000) run characterization on ingested file — Name (branch name)
- 6080b81 is the commit #
Find branch name by commit #
- git branch --all --contains 6080b81
Sync a branch with master
Your branch is based on 'origin/master', but the upstream is gone.
- git checkout test
- git rebase master
- git push origin +test
Your branch is based on 'origin/master', but the upstream is gone.
- git remote add origin giturl
- git push -u origin master
Remove previous gitignore files:
git clean -fX
Delete a branch
git branch -D dev
git push origin :dev
Rename a branch
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
Delete a branch
git branch -D dev
git push origin :dev
Rename a branch
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
Squash commit:
$ git rebase -i HEAD~4
or
$ git rebase -i 97c9d7d
1 r 01cc5a08 Removes open div
2 s a2b6eecf Restores old fonts
3 s 603479ff Cleans left out div
$ git push origin branch-name --force
# Edit last commit message, before pushing, by using
$ git commit --amend
Cheatsheet: https://gist.github.com/davfre/8313299
$ git rebase -i HEAD~4
or
$ git rebase -i 97c9d7d
1 r 01cc5a08 Removes open div
2 s a2b6eecf Restores old fonts
3 s 603479ff Cleans left out div
$ git push origin branch-name --force
# Edit last commit message, before pushing, by using
$ git commit --amend
Cheatsheet: https://gist.github.com/davfre/8313299
沒有留言:
張貼留言