Dec 12, 2014

Git Series: Quick Intro

Git is a software that keeps track of changes and allows you to move back and forth between different versions to compare and see what changed between each one. Git is a VCS (Version Control System). When a VCS is used to manage source code, it’s also called a SCM (Source code management) too

VCS + source code = SCM


Let’s look back


Source Code Control System (SCCS) 1972. Closed source, free, Only for UNIX. It stored the original file and all the changes that went after it, so when you opened the file, it opened the original one and then all the changes were applied (low performance)

Revision Control System (RCS) 1982. open source, cross platform. It kept the most recent file in its whole form with all the previous changes, and only if you want a previous version, you applied the change snapshot to go backwards in time (better performance)

Concurrent Version System (CVS) 1986. Open source, cross platform. You could work with multiple files. Many users could work with a single repository over a network, the concept of remote repositories were introduced.

Apache Subversion (SVN) 2000. Open source, cross platform. It was faster and allowed to save different file formats. It kept track of directories not only of files, SVN applied transactions to update changes through many files and directories and mantain integrity

Bitkeeper scm 2000. Closed source, cross platform. First distributed versions control, it had a community version used for source code of the Linux kernel. In 2005 the community version disappeared

Git 2005. Open source, cross platform. Developed by Linus Torvalds as a replacement for Bitkeeper

Distributed Version Control


Every user maintain their own repositories. Changes are stored as change sets or patches and every user tracks only the changes that are useful for them.

It is a convention to establish a “master” repository and stay up to date with this master repository, but it is just a convention, we don’t have to

No need to communicate with the central server (work offline), it allows you to work independently and then submit your changes for inclusion or rejection

Nov 26, 2014

Ignore files in Git

In Terminal, navigate to the location of your Git repository and  type
touch .gitignore
Check this collection of useful .gitignore templates
This file usually appears in the root of the repository, you can get the root directory using
git rev-parse --show-toplevel
However we can have this file in any sub folder.

To ignore files that was already tracked we need to remove them from the index, but  first of all we need to Commit pending changes to avoid unexpected behavior
git rm -r --cached .
-r Allow recursive removal when a leading directory name is given.
-q git rm normally outputs one line (in the form of an rm command) for each file removed. This option suppresses that output.

git add .
git commit -am “Remove ignored files”
-a Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected

If you get the warning
warning: LF will be replaced by CRLF in <file>The file will have its original line endings in your working directory.
You can simply use
git config core.autocrlf false
In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). It’s nothing to worry about.

References
http://git-scm.com/docs/git-commit
https://help.github.com/articles/ignoring-files/
https://github.com/github/gitignore
http://git-scm.com/docs/gitignore