Difference between revisions of "Git Tips Tricks"
Jump to navigation
Jump to search
(Created page with "= Github specific = == Github and Pull Requests == Common scenario to run into: you've forked some repo and (or because!) there are outstanding Pull Requests (PRs) created on...") |
(add basic git-filter-repo notes) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
Common scenario to run into: you've forked some repo and (or because!) there are outstanding Pull Requests (PRs) created on the upstream project that you want merged into the codebase. This turns out to be relatively easy: | Common scenario to run into: you've forked some repo and (or because!) there are outstanding Pull Requests (PRs) created on the upstream project that you want merged into the codebase. This turns out to be relatively easy: | ||
− | git clone git@github | + | git clone git@github.com:youruser/project.git |
− | cd | + | cd project |
git checkout correctbranchname | git checkout correctbranchname | ||
git pull https://github.com/upstreamuser/project.git refs/pull/12/head | git pull https://github.com/upstreamuser/project.git refs/pull/12/head | ||
git push origin correctbranchname | git push origin correctbranchname | ||
+ | |||
+ | This clones your forked copy of "project" locally, checks out whatever branch the PR is against ("correctbranchname"), then does a combination pull+merge on the upstream project's open PR number 12. | ||
+ | |||
+ | See also, a useful discussion about command line access to pull requests: [https://gist.github.com/piscisaureus/3342247 https://gist.github.com/piscisaureus/3342247]. | ||
+ | |||
+ | = Generic = | ||
+ | == Filtering repositories == | ||
+ | * [https://github.com/newren/git-filter-repo/ https://github.com/newren/git-filter-repo/] -- github project maintainers say use this instead of built-in 'filter-branch' command. | ||
+ | === "promote" subdirectory === | ||
+ | Example use of git-filter-repo: | ||
+ | <pre> | ||
+ | git clone git@gitlab.com:user/bigrepo.git | ||
+ | cd bigrepo | ||
+ | git-filter-repo --path lib/ | ||
+ | </pre> | ||
+ | This keeps history for all files in lib/ and moves it to the top-level. |
Latest revision as of 11:50, 11 December 2020
Github specific
Github and Pull Requests
Common scenario to run into: you've forked some repo and (or because!) there are outstanding Pull Requests (PRs) created on the upstream project that you want merged into the codebase. This turns out to be relatively easy:
git clone git@github.com:youruser/project.git cd project git checkout correctbranchname git pull https://github.com/upstreamuser/project.git refs/pull/12/head git push origin correctbranchname
This clones your forked copy of "project" locally, checks out whatever branch the PR is against ("correctbranchname"), then does a combination pull+merge on the upstream project's open PR number 12.
See also, a useful discussion about command line access to pull requests: https://gist.github.com/piscisaureus/3342247.
Generic
Filtering repositories
- https://github.com/newren/git-filter-repo/ -- github project maintainers say use this instead of built-in 'filter-branch' command.
"promote" subdirectory
Example use of git-filter-repo:
git clone git@gitlab.com:user/bigrepo.git cd bigrepo git-filter-repo --path lib/
This keeps history for all files in lib/ and moves it to the top-level.