Questions tagged [git-mv]

git-mv is a git command that is used to move or rename a file, a directory, or a symlink

- Move or rename a file, a directory, or a symlink. The index is updated after successful completion, but the change must still be committed.

38 questions
2
votes
1 answer

Move git repository to a subdirectory in the same path while preserving all of its history

I have a git repository with >100 commits that I initialized awhile back in the following path: /Users/myusername/ However, all of my commits are actually for files in the…
isosceleswheel
  • 1,516
  • 12
  • 20
1
vote
1 answer

git: rename file and create file with old name in same commit

In my experience, when I rename a file, git will detect the rename on my next commit. However, now I want to rename a file, say from old_name to new_name, and in the same commit, I want to create a new file named old_name. Since a (different) file…
DBear
  • 312
  • 2
  • 9
1
vote
1 answer

Adding back a file in git which was renamed to a different file name

I had a file: a.cs which I renamed to: b.cs and made some logic changes in b.cs Now I realized I need to re-add a.cs BUT keep b.cs. I added back a.cs but I don't see it in the working directory and so I can't add it to the staging area and…
Ace
  • 831
  • 2
  • 8
  • 28
1
vote
1 answer

Undoing a git move in a rebase

In a git repo, I accidentally moved a file, A, to B, instead of deleting A and creating a completely new B. How can I delete A and create a new B during a rebase?
XDR
  • 4,070
  • 3
  • 30
  • 54
1
vote
0 answers

How to move multiple directories from another repo and preserve git log directory behavior?

I've read several threads on moving directories between git repositories, and the one I've settled on using is this one, which makes use of git subtree. Following the steps, everything seems to work well, but the problem comes at the end. I'm left…
user3338893
  • 917
  • 3
  • 10
  • 17
1
vote
0 answers

Git checkout fails on untracked working tree files after git mv

I have a problem with my local branches. When I am trying to do git checkout I get this error message: error: The following untracked working tree files would be overwritten by checkout: ... (list of files) Please move or remove them before…
Soul Reaver
  • 2,012
  • 3
  • 37
  • 52
1
vote
1 answer

Odd `git mv` behaviour

Last month I started to contribute to a GitHub repository by forking the corresponding repo, creating a feature branch and then submitting a pull request. While repeating that process for a couple of days, I ran into a weird problem when renaming…
Christian Heinrichs
  • 786
  • 1
  • 9
  • 28
1
vote
1 answer

Late-rename file after commit in git

Someone changed a file name and its content in a way that git was unable to detect that it was the same file. They also didn't use git mv, so when I got the pull request I saw a new file being added and an old file being deleted, which makes it…
Roberto
  • 11,557
  • 16
  • 54
  • 68
0
votes
0 answers

Rename file and move to different directory using Git and maintain their history

I would like to move a file from one folder to another. File currently resides in /dist/somefile.js, I would rename and move to a different location into a new folder /src/my-newfolder/index.js. I understand when using the mv command, git is…
david-l
  • 623
  • 1
  • 9
  • 20
0
votes
1 answer

Move a file from a directory with one file to another (refactoring)

I have a directory with a single file Foo.java defining a class under package com.a.b.c under a specific package i.e. src/com/a/b/c/Foo.java I want to refactor and move the class in a different package e.g. com.x.y.x i.e. src/com/x/y/z/Foo.java I…
Jim
  • 3,845
  • 3
  • 22
  • 47
0
votes
1 answer

git log after moving file to separate branch

I've moved a bunch of files to a separate branch, to avoid mixing separate histories. Then I moved the files on the new branch to / (so that they can be checked out in a worktree rooted exactly where they were initially located): git branch -c…
usretc
  • 723
  • 4
  • 9
0
votes
0 answers

git: find most recent non-rename commit to a file

git rev-list outputs all version of a file path (stops at renames), git --follow --pretty=%h outputs all versions across moves/renames, but how can I find (non-manually) the latest commit that modified the content of a file (preferably excluding…
usretc
  • 723
  • 4
  • 9
0
votes
1 answer

Should I git mv or just mv the files I'm cherry-picking / rebasing from another directory?

I have some csv files that I modify on a regular basis, they don't really contain any sensitive information, they are just used as imports into a program, and I modify them as requested. Lately I've found what may be a more efficient way to process…
leeand00
  • 25,510
  • 39
  • 140
  • 297
0
votes
0 answers

Refactor files from the main repository to a submodule with history

Take a project with, say, the executable source in the main repository M and dependent libraries in several sub modules S1, S2, etc. The decision is made that some code in the executable should be migrated to the library in submodule S1 to make it…
cycollins
  • 415
  • 4
  • 11
0
votes
0 answers

Different file name in a specific branch

In my git project folder, I need to create a different version of the software, something that of course I can do by creating new branches. The point is that I need to rename different files without loosing the version control; a change in branch-1…
ilGhera
  • 1
  • 4