Git mv Command
In this page:
git mv old_name new_name
git mv file_name directory/
एक File Rename करना
git mv old-name.txt new-name.txt disk पर एक tracked file rename करता है और automatically उस rename को Git में stage करता है, एक command में वह करते हुए जिसके लिए अन्यथा एक manual mv plus अलग git add और git rm calls चाहिए होतीं।
उदाहरण: Renaming a File
git mv old-name.txt new-name.txt
एक File को Directory में Move करना
वही command files relocate भी करता है -- git mv file.txt src/file.txt एक tracked file को Git की history को इससे connected रखते हुए एक अलग directory में move करता है, इसे delete-and-recreate की तरह treat करने के बजाय।
उदाहरण: Moving a File to a Directory
git mv file.txt src/file.txt
कई Files Move करना
आप target directory से पहले उन सबको list करके एक साथ एक destination folder में कई files move कर सकते हैं, जैसे git mv a.txt b.txt docs/, जो हर move को साथ stage करता है।
उदाहरण: Moving Multiple Files
git mv a.txt b.txt docs/
एक Move या Rename Force करना
अगर destination name वाली एक file पहले से exist करती है, Git इसे चुपचाप overwrite होने से बचाने के लिए move करने से मना कर देता है; -f flag फिर भी move force करता है, वहाँ पहले से जो भी था उसे replace करते हुए।
उदाहरण: Forcing a Move or Rename
git mv -f source.txt existing.txt
एक Move Dry-Run करना
git mv -n old.txt new.txt यह दिखाते हुए एक dry run perform करता है कि rename क्या करेगा, बिना actually किसी file को छुए -- कुछ important rename करने से पहले एक quick safety check।
उदाहरण: Dry-Running a Move
git mv -n old.txt new.txt
- file manager में एक file rename करना और फिर सिर्फ
git addचलाना, जबकिgit mv old newदोनों steps एक साथ करता है (हालाँकि Git किसी भी तरह rename detect कर सकता है)। - एक untracked file पर
git mvचलाना, जोnot under version controlके साथ fail होता है। - एक file को न मौजूद folder में move करना, जैसे
git mv file.txt src/file.txtमें, जहाँsrcdirectory पहले बनानी ज़रूरी है।
Chapter Quiz — Complete all 18 topics to unlock
0/18 topics done
Complete these topics first:
- Git init Command
- Git New Files
- Git Staging Environment
- Git clone Command
- Git status Command
- Git help Command
- Git add Command
- Git commit Command
- Git tags Command
- Git stash Command
- Git log Command
- Git diff Command
- Git show Command
- Git rm Command
- Git mv Command
- Git restore Command
- Git clean Command
- Git ignore (.gitignore)