Git – Paolo Redaelli https://monodes.com/predaelli A civil engineer with a longlife fondness for Software Libero Sat, 31 Aug 2024 22:23:46 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 91795679 Git: Copy a file or directory from another repository preserving the history https://monodes.com/predaelli/2024/09/01/git-copy-a-file-or-directory-from-another-repository-preserving-the-history/ https://monodes.com/predaelli/2024/09/01/git-copy-a-file-or-directory-from-another-repository-preserving-the-history/#respond Sat, 31 Aug 2024 22:23:45 +0000 https://monodes.com/predaelli/?p=11886

How to copy a file or directory from another GIT repository while preserving its history?

Internet is full of magic formulas each one more complex.

Here I’m proposing a much simpler and faster one that is to make a git format-patch for the entire history of the file or subdirectory that we want and then import it into the destination repository.

mkdir /tmp/mergepatchs
cd ~/repo/org
export reposrc=myfile.c #or mydir
git format-patch -o /tmp/mergepatchs $(git log $reposrc|grep ^commit|tail -1|awk '{print $2}')^..HEAD $reposrc
cd ~/repo/dest
git am /tmp/mergepatchs/*.patch

Simple and fast :)

Source synaptic fault http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/ ]]>
https://monodes.com/predaelli/2024/09/01/git-copy-a-file-or-directory-from-another-repository-preserving-the-history/feed/ 0 11886
Never* use git pull – YouTube https://monodes.com/predaelli/2024/06/01/never-use-git-pull-youtube/ https://monodes.com/predaelli/2024/06/01/never-use-git-pull-youtube/#respond Sat, 01 Jun 2024 20:41:00 +0000 https://monodes.com/predaelli/?p=11688

    Just a quick summary mostly for myself:

    How to use git pull --rebase to keep your team’s commit history clean.

    Command for creating the ‘git pr‘ alias (so you can copy-paste): git config --global alias.pr "pull --rebase"

    1. Always try git pull --rebase first. It if works, you’re done!
    2. If you get a merge conflix, you can undo everything with git rebase --abort
    3. Then just pull “normally” using git pull, or do an interactive rebase (advanced)
    ]]>
    https://monodes.com/predaelli/2024/06/01/never-use-git-pull-youtube/feed/ 0 11688
    Find and restore a deleted file in a Git repository https://monodes.com/predaelli/2016/01/21/find-and-restore-a-deleted-file-in-a-git-repository/ https://monodes.com/predaelli/2016/01/21/find-and-restore-a-deleted-file-in-a-git-repository/#comments Thu, 21 Jan 2016 17:17:04 +0000 http://monodes.com/predaelli/?p=915
  1. Use git log --diff-filter=D --summary to get all the commits which have deleted files and the files deleted;
  2. Use git checkout $commit~1 filename to restore the deleted file.
  3. Sorgente: Find and restore a deleted file in a Git repository – Stack Overflow

    ]]>
    https://monodes.com/predaelli/2016/01/21/find-and-restore-a-deleted-file-in-a-git-repository/feed/ 1 915