Another quick git tip, this time on how to remove a file or directory from a repo, but not delete the actual local file.
To remove a file, it’s pretty simple:
git rm –cached myfile
And to do a directory and all files in it:
git rm –cached -r mydirectory
Obviously after this, you should do a commit message and sync the repo with your remote host
Just a quick tip for creating a new repo with existing files.
Create a new repo on your preferred solution (I use Bitbucket but the other main choice is Github, it’s all about what works for you)
Change to your project directory
> cd ~/git/project
Initialize the local directory as a repo
> git init
Add all files to the repo
> git add .
Write your first commit message
> git commit -m ‘First commit’
Tie your local files and remote repo together. For the url, an example would be ssh://firstname.lastname@example.org/daevien/nixgeek.git, but the method to find it varies depending on your provider.
Bitbucket shows it at the top of the main page and GitHub shows it along the right side.
> git remote add origin repo_url_here
Have git verify it can connect to the remote repo
> git remote -v
Push your initial commit to the remote url
> git push origin master
Thats it, your repo is created and initial update complete. Now to continue your content and update it as needed.