Git as a must
If you haven't yet used Git, now is good time to utilize it. It is most powerful tool for collaboration between multiple developers, system administrators, operators or anyone who is using any kind of code. I had a friend before who used it as a backup solution, too!
There are many companies who are using services based on Git, but most popular are GitHub and BitBucket. GitHub requires you to pay if you want to have private repository (the place where you store your data), BitBucket is free.
You start with git by going into a directory which you want to share with other people or systems (such as Github) and then initialize it with the command:
$ cd your-code
$ git init
And setup your name and basic info:
$ git config --global user.name "Igor David"
$ git config --global user.email igor.david@igor.david
Now, I won't go here into details about all Git things since there are LOT of GREAT documentation around and websites, one of the most useful is this: http://ohshitgit.com/
But I will summarize the most used commands for me:
$ git status -> check current status
$ git add . -> add all files in current directory
$ git commit -a -m "comment" -> commit all files with adding "comment"
$ git add -a --amend -> add changes to existing commit by amending. This is very useful if you want to make small change and add it to existing commit but don't make any visibility of that. Don't cheat! :)
$ git rebase -i -> Let's say that you have three commits, A B and C and you want to "squash" them into one and make your commit history looks nice. You can execute this command, put letter "p" for the commit which you want to pick, put letter "s" for the commits which you want to squash into the one marked with "p", and voila! Git will do this for you. BE VERY CAREFUL NOT to forget to choose some of the commits as they will be deleted.
$ git remote -v -> check remote repository status
$ git fetch upstream -> fetch data from remote upstream
$ git rebase upstream/develop -> rebase your current commit on the top of everyone's else commits. This means that your current commit will be put as a first commit in the git history, making it great for collaborating with other team members.
$ git reflog -> observe which HEADs are present and which actions happened, so you can for example undo some changes if required
$ git reset --soft HEAD@{1} -> once you want to "jump" to certain HEAD, you can do it with this command
$ tig -> this is separated package but VERY useful