Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Monday, January 18, 2021

Git: Moving files to a new repository while preserving history

> git --version
git version 2.18.0
This method did not work for me: Move files from one repository to another, preserving git history
But this one did the trick: Moving Files and Directories to a New Repository in Git

Here is the list of commands used in order to extract the contents of the perl/ directory from the connectmv repo. into the ss-sms-vas repo.:
> mkdir cloneA
> cd cloneA/
> git clone git@github.com:<MY_TEAM>/connectmv.git
> cd connectmv/
> git subtree split --prefix perl/ --branch my-subtree
> git checkout my-subtree
> git remote add repoA git@github.com::<MY_TEAM>/ss-sms-vas.git
> git pull repoA main --allow-unrelated-histories

> git push -u repoA my-subtree:main
> cd ../../
> rm -rf cloneA/

> cd ss-sms-vas/
> git pull
> git lol lib/MBQT/mod_perl/AbstractVas.pm 
* 72be224f (Thu Jan 7 18:32:47 2021 Jerome G) PLTBUGS-8700: exploded USSD CDR per process
* 680a9ff2 (Thu Jan 7 13:51:45 2021 Jerome G) PLTBUGS-8700: removed unlock
...

Friday, July 17, 2020

Git: view unpushed commits

Source: Viewing unpushed Git commits
[jerome@jeroboam] > git lol @{u}..
* 00e9d99cf (HEAD -> PLTFRS-12002_Move_USSD_VAS_to_AWS) (Mon Jun 1 12:00:14 2020 GitHub) Merge pull request #726 from AirVantage/PLTFRS-12002_Move_USSD_VAS_to_AWS

Tuesday, September 4, 2018

git: merge files from another branch

Source: Git tip: How to "merge" specific files from another branch
git checkout [TARGET_BRANCH]
git checkout [SOURCE_BRANCH] my_file1 my_file2

Wednesday, August 1, 2018

git: rename a branch

Source: Rename a local and remote branch in git

Rename local branch.
git branch -m new-name
Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
Reset the upstream branch for the new-name local branch.
git push origin -u new-name

Wednesday, July 4, 2018

git: use p4merge on macOS

Source: Customizing Git, section External Merge and Diff Tools.

Wednesday, January 11, 2017

Thursday, December 15, 2016

Git: list files changed in a branch

git checkout my_branch
git diff --name-only master...

Tuesday, November 15, 2016

Git: use external diff command

git difftool --extcmd=diff sql/mbqt_prov_api.sql

Friday, February 12, 2016

Git: see only one user's commits

git lol --author='John Smith' --name-only

Tuesday, February 2, 2016

Git: cancel a git stash apply

If you haven't pushed:
git reset --hard [last_good_commit]
or if you have pushed:
git revert [last_good_commit]

Monday, November 30, 2015

Git: check if something to pull

git remote -v update