Sunday, April 9, 2017

Introduction to Git

A version control system, like CVS, SVN, Perforce or ClearCase. Contrary to CVS or SVN, Git is a distributed version control System.
-No central repository
-Everybody has a local repository
-Local branches are possible, and very important
-Easy exchange of code between developers
-Well-suited to the collaborative development model used in open source projects

sudo apt-get install git-core
git config --global user.name 'My Name'
git config --global user.email me@mydomain.net
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
git log -p will list the commits with the corresponding diff
git log v2.6.30..master
git log v2.6.29..v2.6.30 MAINTAINERS
git pull:
-Fetch the new changes from the remote repository (git fetch)
-Merge them in the current branch (git merge)
git tag -l
git checkout <tagname>
git status

git checkout -b <branchname> (git branch <branchname> + git checkout <branchname> )
git branch -l
git branch -a

Git has a feature called the index, which allows you to stage your commits before committing them. It allows to commit only part of your modifications, by file or even by chunk
On each modified file: git add <filename>
Then commit. No need to be online or connected to commit: git commit
If all modified files should be part of the commit: git commit -a
First step is to generate the patches: git format-patch -n master..<yourbranch>
Will generate one patch for each of the commits done on <yourbranch>
The patch files will be 0001-...., 0002-...., etc.

Second step is to send these patches: git send-email --compose --to email@domain.com 00*.patch
Create a bare version of your repository
cd /tmp && git clone --bare ~/project project.git && touch project.git/git-daemon-export-ok
Transfer the contents of project.git to a publicly-visible place (reachable read-only by HTTP for everybody, and read-write by you through SSH)
Tell people to clone http://yourhost.com/path/to/project.git

Push your changes using: git push ssh://yourhost.com/path/toproject.git srcbranch:destbranch

No comments:

Post a Comment