Wiki source code of Git QuickStart

Show last authors
1 = Git QuickStart =
2
3 **Git** (download from [[__here__>>http://git-scm.com/downloads]]) is a Distributed Version Control Systems (DVCSs).
4
5 >Brief description
6
7 A Version Control System is a system that records changes to a file or set of files over time so that you can recall specific versions later.
8 Centralized Version Control Systems (CVCSs) - such as CVS, Subversion, and Perforce - have a single server that contains all the versioned files, and a number of clients that check out files from that central place. For many years, this has been the standard for version control.
9 In Distributed Version Control Systems (DVCSs) - such as Git, Mercurial, Bazaar or Darcs - clients don’t just check out the latest snapshot of the files: they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it.
10
11 >Guides
12
13 To download a **"Quick Start"** pdf guide (edited by [[__Stefano Mariani__>>http://apice.unibo.it/xwiki/bin/view/StefanoMariani/]]) click [[__here__>>http://apice.unibo.it/xwiki/bin/download/TuCSoN/Git/Git-quick-start.pdf]]. For a more **in-depth guide** refer to [[__GitBook__>>http://git-scm.com/doc]], from which most of the material in such pdf guide is taken.
14
15 == Basic Command line list ==
16
17 As a quick-access reminder, here follows a list of Git most known and used **command line** "commands" (sorry for the awkward wordplay) along with a brief description (uppercase-initiated strings are variables with their intuitive meaning):
18
19 (% style="list-style-type: disc" %)
20 * ##git init## - to start tracking an existing local project (type in project dir);
21 * ##git clone [Url]## - to mirror locally an existing remote Git repository (type in your preferred target dir which will host your local copy of the project);
22 * ##git add [Filepath]## - to begin tracking a new file (works with dirs recursively);
23 * ##git commit -a -m "[Message]"## - to register the current state of your project into Git repository;
24 * ##git rm ~-~-cached [Filepath]## - to stop tracking a tracked file without removing it from your hard disk (works with dirs recursively);
25 * ##git status## - to know which files are in which state (committed, staged, untracked basically);
26 * ##git log## - to know the repository history (lists all of your previous commits);
27 * ##git branch## - to list existing branches;
28 * ##git checkout -b [Branchname]## - to create a new branch and suddenly switch to it (create a local copy of your working project and start working on it);
29 * ##git merge [Branchfrom] -m "[Message]"## - to merge an existing branch into your current working branch;
30 * ##git tag -a [Tagname] -m "[Message]"## - to create a named release of your current working project (a "tag", tipically a non-modifiable snapshot of your current branch);
31 * ##git remote add [Alias] [Url]## - to create a shortname to use in place of an existing remote repository complete url (it does not pull dow anything);
32 * ##git pull [Remotealias]## - to download all changes made in the target remote repository into your local copy of that repo;
33 * ##git push [Remotealias] [Branchname]## - to upload the specified branch to the target remote repository (succeed only if nobody has pushed since your last push)
34 * ##git push [Remotealias] ~-~-tags## - to upload all your local tags to the target remote repository;
35 * ##git checkout -b [Branchname] [Remotealias]/[Remotebranch]## - to start tracking an existing remote branch on the specified remote repository, naming it locally as you prefer (needs ##git fetch origin## first);
36 * ##git clone -b [Branchname] [Remotealias]## - to clone only a single branch other than the whole remote Git repository.
37
38 >Advanced Command line list
39
40 Some more involved commands, useful in a plethora of situations:
41
42 (% style="list-style-type: disc" %)
43 * ##git ls-tree -r [Branch] ~-~-name-only## - to show tracked files
44 * ##git diff ~-~-name-status [Branchfrom]..[Branchto]## - to have a quick look at the main differences between two live branches of the project;
45 * ##git diff [Branchfrom]:[Filepath] [Branchto]:[Filepath]## - to have a complete description of the differences that two branches have w.r.t. the given file;
46 * ##git checkout [Branchfrom] [Filepath]## - to "merge" a single file from the given branch into the working one (notice actually it is more likely an overwrite other than a merge, so be careful);
47 * ##git commit ~-~-amend -m "[Msg]"## - to replace the last commit message with ##Msg##;
48 * ##git checkout ~-~- .## - to discard all the staged changes at once;
49 * ##git checkout -b [Branchto] [Tagfrom]## - to create a branch out of a tag and suddenly switch to it;
50 * ##git reset ~-~-hard [CommitHash]## - to revert the file system status to the given commit;
51 * ##git push [RemoteAlias] :[BranchToDelete]## - to delete a remote branch.
52 * ##git log [TagFrom]..[TagTo] > changelog.txt## - to print out to a text file the commit log between two tags
53 {{include reference='Environment'/}}

Logo

Contacts

Giovanni Ciatto email  |  Andrea Omicini email  |  Stefano Mariani email

Links

Official  |  APICe  |  Google Code  |  SourceForge  |  FaceBook

2P  |  A&A  |  MoK  |  ReSpecT  |  T4J  |  T4Jn