sudo apt-get install openssh
$ ssh username@hostname
ssh-keygen -t rsa
The private key is at ~/.ssh/id_rsa
while the public key is at ~/.ssh/id_rsa.pub
The server needs your public key to authenticate the connection.
central VCS v/s Distributed VCS
Why Version Control
Examples : svn, cvs, mercurial, bzr, etc
This is just a simple walkthrough. You are encouraged to try out these steps on your own.
git init
creates a new repositorygit clone <url> [folder]
clones a repo from the servergit add <filename>
adds files to indexgit add .
adds everything to indexgit commit
creates a commitgit commit -a
adds all modified files to the index and starts a commitgit checkout <ref>
changes your working directory to a commit/tag/branchgit checkout -b branchname
creates a new branch and shifts to itgit branch
shows a list of all branches & the current branchgit branch <branch>
creates a new branch, but does not switch to itgit merge branchname
merges the branch with the current branchgit tag
marks a tag for the current commitgit pull [remote] [ref]
fetches and merges the branch/commit with the current HEADgit fetch [remote] [ref]
fetches the commits for mergingpull
= fetch
+ merge
checkout -b
= branch
+ checkout
//Create and checkoutRead more over here
branch
is an active line of development.commit
is a snapshot of the working directorytag
is an alias of a particular commitHEAD
is a pointer to the current checked out branchtree
is the internal representation of working directory in gitblob
is the internal representation of files in gitindex
is a staging area for the commit in progressThis is what Github follows. People create their own fork version of the repo, and send back pull requests
A single repository shared among various people can be used successfully if the project is closed, and has known developers This is mainly for organizations and trusted developers
Mainly from here
Topics include branches, stable, hotfix, release, development, feature branch etc.
remotes
push
, pull
, fetch
, merge
e
on a file)A few more git commands
git log
allows you to see your historygit log --oneline
gives single line historygit log --pretty
gives better outputgit log --graph
shows your commit graphgitg
, git-cola
, qgit
, giggle
and the windows git-gui as.gitignore
file to store system specific stuff (configuration, databases, temp files, cache, build)tig
is an awesome commit browser that runs on the command line.To install any of the packages mentioned above, just run sudo apt-get install package
in ubuntu.
git config user.name
and git config user.email
should be setupWhen you make commits on git, it uses your default text editors to type the commit message. This is set to vim
in Windows and Linux. Linux folks can change it to anything else by setting the $EDITOR variable by the following command: export EDITOR=nano
(Replace nano with the editor of your choice like gedit geany etc)
You can also save the setting in your git global configuration, by : git config --global core.editor "nano"
As per this question on SO, you can use Notepad++, or notepad etc on git on Windows as well.
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Take care about the slashes, and the path to your editor of choice. Don’t use notepad, it screws with the newlines.
If you’re stuck with vim for some reason, do the following in the commit window
i
to go to insert modeEsc
:wq
. The colon is importantEnter
Remember, an empty commit message aborts the commit. Also the best way to commit easily is:
git commit -m "Commit Message Here"
to just type the commit message on the command line, and leave out all the hassle of the editor
To learn how to use vim effectively, type ‘vimtutor’ in terminal.
Git allows you to defined aliases for certain commands. These faster ways of using git create several additional commands for git, such as git release
, and ga
etc
Also see tig
, which is a cli repo browser for git.