Change master branch in Git

1

I'm new to programming but I have some notion, my question is this:

I executed the command git init in the folder of my user, then from the terminal when I am at the height of that folder in the terminal I am shown ~git: (master) , instead of having executed the previous command in the indicated folder .

My question is how to change the location of the master branch, so that when it is in the indicated folder it indicates that I am in the master branch and it does not show it in my user folder, or if I have to delete the branch, since in my user's folder I have more folders belonging to the system, such as documents, music, etc. and I do not want to combine that folder with git .

    
asked by CRISTOPHER FRANCISCO HERRERA B 18.04.2018 в 23:28
source

3 answers

0

If by mistake you made git init in a folder you just have to do:

rm -rf .git

that will erase the repository started in that folder. then you do the git init in the folder that you want to share with git

    
answered by 18.04.2018 в 23:41
0

As long as you do not make changes or a push you can move the folder .git to where it should be

that's where the file stories are stored

to know what changes there were:

$ git status

to see if the .git folder exists

$ ls -al

to move it to another folder:

$ mkdir ./otracarpeta
$ mv .git ./otracarpeta

If you only made git init in the wrong place and nothing else, you can delete the folder .git

If you have already made changes to the correct folder and want to keep the history, after moving the folder .git you will have to do git status and see what changes are and what are not (usually it will tell you that they moved the folder files)

    
answered by 18.04.2018 в 23:45
0

Git keeps all repository files in a hidden folder called .git . When you execute the git init command in any folder, that folder becomes a repository of Git , you can verify this by executing the ls -a command and checking that the hidden folder has been created .git that contains the newly created repository information.

What you have done is create a new repository in your user folder. If you have not yet made commits in this repository, you can delete it by directly deleting the .git folder inside your user folder with the rm -rf .git command. Then you can create a new repository in the indicated folder, by placing it in it and running the git init command again to initialize a new repository of Git in that location.

    
answered by 18.04.2018 в 23:49