Git is a distributed revision control system. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Although it is commonly used via the command line, many GUIs such as the newbie-friendly SmartGit exist (see Links).
Installation and Configuration
Git comes preinstalled on latest version of MX Linux. For other systems or if you removed it, you can install git client through Synaptic, or with this command
apt-get install git-core
Set some useful global variables
git config --global user.name "YourName" git config --global user.email "[email protected]"
Set up a git repository
- Depending on your purpose you can either clone locally a remote repo (downloading all the files to the local disk), for example, downloading the latest Linux kernel
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
The git repository will be created in linux, you can cd to that directory:
To re-sync (update) the local Git repo with the remote repo you can run this command (while in linux-2.6 directory):
To push changes (if you have rights to publish on the remote repo) you can use this command:
2.Another way to set a repository is to initializes a directory as a Git repository:
Once you cloned or initialized a Git repository you can start to edit file. Files are not tracked automatically by Git, to add files to “staging” area you need to use the add command:
git add filename
(for specific file(s))
git add .
(for all the files in the current directory and its sub-directories)
Once you reach a point where you are satisfied with the changes you can commit the changes with:
git commit -am “commit message”
Common options: -a — automatically stage all tracked, modified files before the commit (You still need to run git add to start tracking new files) -m — adds a commit message
Branching is probably the most important feature of Git. You might want to create branches for multiple purposes: experimenting, create different branches for different features, keep copies of stable versions in different branches, branches for patches, etc.
You can create a branch with git branch branchname, switch into that context with git checkout branchname, record commit snapshots while in that context, then can switch back and forth easily. When you switch branches, Git replaces your working directory with the snapshot of the latest commit on that branch so you don’t have to have multiple directories for multiple branches. You merge branches together with git merge branchname_to_be_merged.
GitHub is the single largest host for Git repositories, and many MX applications are housed there.
Contributing on GitHub
This is the general workflow for contributing code on GitHub: From github.com interface Fork the repo you want to contribute to -> Clone it to your harddrive -> Make changes and Commit -> Push changes to your repo -> From github.com interface create a “Pull Request”.