Git and Bitbucket
Version controle is considered an indispensable part of current programming practice. Git (the programme) and GitHub or Bitbucket (the repositories) are common tools to implement version controle and, no less important, facilitate a regular backup practice. Since Bitbucket still is free and private, it is my preferred repository at this moment (Git – Reference).
Common actions in Git are:
$ git init $ git add -A $ git commit -m 'some description'
You can create a .gitignore file to indicate what not to include in version controle (for details see: Git – Reference).
$ git status
After a connection has been setup, you can find out about the connection you have and push:
$ git remote -v $ git push -u origin master
Here, origin is the (default) name of the remote yoy push to and master is the name of the (default) branch that you push.
If you need to make minor changes you could amend:
$ git commit --amend $ git push -f origin master
On windows git bash, you enter a vi/vim-like editor. Press i to enter inline insert mode. Type the description at the very top, press esc to exit insert mode, then type :x! (now the cursor is at the bottom) and hit enter to save and exit. If typing :q! instead, will exit the editor without saving.
Bitbucket – Initial connection
To connect with a repository for the first time, the repository should be available and git should know where it is. A new repository is made in your account at bitbucket.org with [(+) repisitory]. To avoid confusion over names I prefer to use the local project_name. It is better to not include a README in the repository, since git will refuse to push to a none-empty repository.
Now teach git on the local machine where the repository lives:
$ git remote add origin https://firstname.lastname@example.org/user_name/project_name.git
The location is registered on the local machine in .git. For the time being, I can define this only once, since I did not yet identify options for remove or replace.
To clone the repository go to bitbucket and copy the clone link.
$ git clone https://email@example.com/user_name/project_name.git
Now, you check your remotes and fetch (without merge) or pull (includes) any new changes.
$ git remote -v $ git pull [remote]