Horje
Git - Rename

Renaming the file is very important when we are working on a project. Git Rename is used to rename a file in the working directory. Suppose we are working in a team and any fellow developer created the file and we want to rename it using Git or Github so this command help us to do so. We may change the name of the file even though we created the file due to some reason. To rename any file or folder, use git mv command which takes two arguments. The first argument is the source and the second is the destination. We can easily rename any file using the git command and the new name will be assigned to that file. We can rename the file using GitHub or the command line. 

We’ll discuss both approaches.

  1. Using GitHub (Same applies to GitHub Desktop)
  2. Using the Command Line (terminal/ Power Shell)

Way 1: Rename using GitHub 

Step 1: Open GitHub.

Step 2: Open the repository to rename any file in that repository.

Step 3: Open the file which we want to rename.

Step 4: Click the edit button and rename the file.

Step 5: After renaming the file, commit the changes.

Step 6: A file with the new name will be saved.

Way 2: Renaming using the Command Line

Step 1: Open Git Bash.

Step 2: Open the repository.

Step 3: Rename the file using the command:

git mv old_filename new_filename

Step 4: Use the “git status” command to check the changes.

Step 5: Commit the renamed file.

git commit -m "Renamed_file"

Step 6: Push the changes using “git push origin branch_name”

It is as shown in below pictorial aid.




Reffered: https://www.geeksforgeeks.org


Git

Related
Ignoring Files and Folders in Git Ignoring Files and Folders in Git
How to Import a Flutter Project from GitHub? How to Import a Flutter Project from GitHub?
Introduction to GitHub Actions Introduction to GitHub Actions
How to Set Git Username and Password in GitBash? How to Set Git Username and Password in GitBash?
How to Add Images on README .md File in a GitHub Repository From the Local System? How to Add Images on README .md File in a GitHub Repository From the Local System?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
10