Version Control & Git Commands
What is version control?
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
Why is version control important?
If you are reading this, it’s possible that you are updating documents that look something like this: index.html.erb.
Let’s get away from this and on to something that will not only allow you to control your source code and files, but become more productive as a team. If this sounds familiar:
- Communicated with your team via email about updates.
- Made updates directly on your production server.
- Accidentally overwrote some files, which can never be retrieved again.
- You can now look forward to this instead:
- File names and directory structures that are consistent for all team members.
- Making changes with confidence, and even reverting when needed.
- Relying on source control as the communication medium for your team.
- Easily deploying different versions of your code to staging or production servers.
- Understanding who made a change and when it happened.
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.
As Git is a distributed version control system, it can be used as a server out of the box. Dedicated Git server software helps, amongst other features, to add access control, display the contents of a Git repository via the web, and help managing multiple repositories.
Most Popular .git servers are
GitHub is a web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features. Unlike Git, which is strictly a command-line tool, GitHub provides a web-based graphical interface and desktop as well as mobile integration. It also provides access control and several collaboration features such as wikis, task management, and bug tracking and feature that can be helpful for projects.
Bitbucket is a web-based hosting service for projects that use either the Git (since October 2011) or the Mercurial (since launch) revision control systems. Bitbucket offers both commercial plans and free accounts.
Configure user information for all local repositories
Sets the name you want atached to your commit transactions
Sets the email you want atached to your commit transactions
Enables helpful colorization of command line output
Start a new repository or obtain one from an existing URL
Creates a new local repository with the specified name
Downloads a project and its entire version history
Review edits and craf a commit transaction
Lists all new or modified files to be commited
Snapshots the file in preparation for versioning
Unstages the file, but preserve its contents
Shows file differences not yet staged
Shows file differences between staging and the last file version
Records file snapshots permanently in version history
Name a series of commits and combine completed efforts
Lists all local branches in the current repository
Creates a new branch
Switches to the specified branch and updates the working directory
Combines the specified branch’s history into the current branch
Deletes the specified branch
Relocate and remove versioned files
Deletes the file from the working directory and stages the deletion
Removes the file from version control but preserves the file locally
Changes the file name and prepares it for commit
Browse and inspect the evolution of project files
Lists version history for the current branch
Lists version history for a file, including renames
Shows content differences between two branches
Outputs metadata and content changes of the specified commit
Erase mistakes and craf replacement history
Undoes all commits afer [commit], preserving changes locally
Discards all history and changes back to the specified commit
Save and restore incomplete changes
Temporarily stores all modified tracked files
Lists all stashed changesets
Restores the most recently stashed files
Discards the most recently stashed changeset
Register a repository bookmark and exchange version history
Downloads all history from the repository bookmark
Combines bookmark’s branch into current local branch
Uploads all local branch commits to GitHub
Downloads bookmark history and incorporates changes