Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github folder structure change

Tags:

git

github

I am using Github for a website project. I have been checking in changes for a while now, but I now want to change my folder structure, basically organize the files better. Will this mess up my Github repository? If yes, what's the best way for me to ensure my versions stay intact and my new folder structure is synchronized with Git?

like image 483
ayushmat316 Avatar asked Apr 01 '15 22:04

ayushmat316


People also ask

How do I move a file to a different directory on GitHub?

You can move a file to a different directory on GitHub or by using the command line. In addition to changing the file location, you can also update the contents of your file, or give it a new name in the same commit.

How do I add changes to a Git staging area?

Start by moving your .git file to the folder that you want to go to. Then navigate to that folder. Then add all the changes to the staging area. Git will detect these files as renamed versions of old files that were 'lost' and so no history will be lost. $ git add . Commit all the changes with the -a command. The -a command stands for all.

Can I change the location of a file in a repository?

In addition to changing the file location, you can also update the contents of your file, or give it a new name in the same commit. If you try to move a file in a repository that you don’t have access to, we'll fork the project to your personal account and help you send a pull request to the original repository after you commit your change.

How do I commit all changes to a git repository?

Commit all the changes with the -a command. The -a command stands for all. It tells the commit command to automatically stage files that have been modified and deleted whilst new files that you have not told Git about are not affected. Finally, push the changes to your repo.


1 Answers

In terms of Git, these will be simple file renames. To keep things simple, do the restructuring with git commands:

git mv foo.c bar.c
git mv old_dirname new_dirname
git commit

As you can see, you can rename individual files or entire directories as well.

Git is able to follow individual file histories across renames:

git log --follow bar.c

To make life easy for git, if you rename or move a file, do not change its contents in the same commit.

like image 111
SzG Avatar answered Sep 24 '22 05:09

SzG