GIT Version control
Version Control • Sharing code via a centralized DB • Also provides for • Backtracking (going back to a previous version of code), • Branching (creating different versions) and • Resolving differences in code updated by different programmers
Popular VCS • Subversion • Most open-source projects use Subversion as a repository because other larger projects, such as SourceForge, Apache, Python, Ruby and many others, use it as well. Google Code uses Subversion exclusively to distribute code. • many different Subversion clients are available. • Windows has Tortoise SVN • Mac: Versions • Xcode integrates a Subversion client
Popular VCS • Git • Initially developed by Linux kernel creator Linus Torvalds • distributed version control system. There isn’t one centralized code base to pull the code from. Different branches hold different parts of the code. • Used by Linux kernel, WINE, Fedora, etc. • Most famous client: github
Popular VCS • Mercurial • open-source distributed version control system, like Git. • designed for larger projects, most likely outside the scope of designers and independent Web developers. • extremely fast, and the creators built the software with performance as the most important feature. • See http://mercurial.selenic.com/wiki/ • comes equipped with a stand-alone Web interface • Easier to use than GIT
Popular VCS • Other VCS: • Bazzar (http://bazaar.canonical.com/en/ ) • LibreSource (http://dev.libresource.org ) • Monotone (http://www.monotone.ca )
git • Can create a local (on your hard drive) git repository • Via Xcode (option when you create a project) • By hand • Go to the project directory in the Terminal • Create a .gitignore file (optional) • Type: gitinit • Type: git add . • Type: gitcommit –m ‘Initial checkin’ • Go to Xcode and choose: File->Source Control->Refresh Status
The state of your files • Git has 6 states: • Ignored • Untracked: Git sees the file, but it’s neiterh in the repository nor staged for adding to the repository. • Modified: Previous contents are in the repository, but this file won’t be added until it’s staged • Staged: the file has been designated for inclusion in the next commit. • Unmerged: you changed the file and attempted to pull in changes from another repository, and the two sets of changes couldn’t be reconciled. Git highlights the conflicts. You must resolve. • Unmodified: file’s current state is what’s in the repository.
The state of your files • Xcode has 5 states: • Modified: an “M” badge on the file. Previous contents are in the repository, but the file has not been committed. • Unmodified: file’s current state is what’s in the repository. No badge on the file. • Added: you created a new file in the project or added an existing one and copied it to the project. Xcode automatically stages the file for the next commit. • Conflicted: with a red “C”. When you merge changes from another repository into your own, it may not be possible to determine which lines from which flies are to survive the merge. • Unknown: marked with a “?” The file is in the project directory but not in the repository. Simliar to Git’s “untracked” state.
Create a new repository at github • In your user bar at the top right of any page, click the "Create a New Repo" button • Select the account you wish to create the repo on • Enter a name, select to make the repo either public or private and click "Create repository” Account to use
Clone the git repository on your local hard drive • Go to the place where the new folder will live • Get the URL from the Git-Hub project gitclone https://github.com/barrj/Intro_to_Classes.git This is the URL from the Git-Hub
Connect to a GitHub repository from your computer • Another way of creating a git repository on your drive • go to the folder that you’ll be using as your development folder. • create a folder for this specific Repository (“Hello-World” in this example) by running the following command from your Terminal Window: mkdirHello-World • go into your new folder and run the following command from your Terminal: git init • This will initialize a local Git Repository for you. • Git must be installed on your computer already • Now put a .gitignore file into the .git directory (see http://www.ithaca.edu/barr/Student/CS345/Examples/gitignore_example.txt )
Connect to a GitHub repository from your computer • You should see a hidden folder called “.git” in your folder when you run the “ls –a” command. • Next you need to link your local Git Repository to your remote GitHub Repository. To do this you will to run the following command: git remote add origin https://github.com/barrj/Intro_to_Classes.git • You can get the URL from your GitHub repository. • pull to get the initial files gitpull origin master master indicates the master branch. If you want to start with a different branch, you must indicate this.