# Starting git on a folder
# Starting BitBucket repo
# It’s Pretty much the same process for any other git service like GitHub.
BTW, the main difference between GitHub and BitBucket services is that in Github it’s free to create public reops, and in BitBucket it’s free to create private repos.
(Public repos, the whole world can see. Private repos, are only yours to see, or anyone else you choose to share it with).
Create a repo in the web interface (BitBucket Website).
Create a folder on local machine (the root folder that will contain your project).
let’s say ~/username/sites/myWebsite
In the command line do:
cd ~/username/sites/myWebsite git init git add . git commit -m ‘Inital Commit’ git remote add origin <repo-url> git push origin master
git init – start a git repo inside your folder.
git add . – Add all of the current folder files to your next commit.
git commit -m ‘Inital Commit’ – “save” or commit, create a commit with the name “Inital Commit” (you can give it any name you want).
git remote add origin <repo-url> – here copy and paste the repo url from BitBucket
git push origin master – push your changes, (your new commit) to the BitBucket Repo.
# Removing all latest changes (deleting them)
If you made some changes, you don’t want them (at all), and just want to checkout a different commit, (go back in time, if you will).
you will get an error as long as there are unstated files, to remove them do:
git clean -f -d # remove untracked files
IF you want to commit all files except certain files (like config files with Passwords, or just trash files like .codekit) that you only need on your local machine. You need to tell git to ignore these files, the way to do it is to create a
Create a .gitignore file
nano .gitignore (or just don't be weird and create a file in a different way).
add whatever you want git to ignore like:
.DS_Store // this will ignore the .DS_Store files that is created by MAC OS.
IF you want to ignore a complete dir with all of the files in the dir and subdirectories
If you want to ignore all files with some extension do (ex: ignore all .log files):
If you want to add comments to the .gitignore, (notes for yourself, because you keep forgeting what you are doing) do:
# this is a comment
then to make the .gitignore take effect do:
git rm -r --cached . git add . git commit -m "fixed untracked files"
# General Commands
git status – get the status of a git repo
git log – see commits of the repo
git init – start a git repo
git add . – stage all changed files to the next commit
git commit -m ‘title of commit’ – committing a repo with a title.
git checkout <name of branch or master> – checkout different commit/branch
git pull – pull changes of repo from origin reposetory
git push – push changes of repo to origin reposetory
git checkout -f – will checkout master with force (ignore all changes, you will lose all untracked files).
git clean -fd – remove untracked files, -f – force it, -d – remove also directories that are untracked.