Sie sind auf Seite 1von 2

Git Command Related Document

1. To Create a new repository in your system :


Create directory>goto that directory using terminal or cmd
prompt> type git init
2.Checkout a repository in local system and create a working
copy of a local repository.
goto that directory where we need to check out codebase>type git
clone along with /path/to/repository.
When we are using remote server then command will be
git clone username@localhost:/path/to/repository
3.Work Flow of Git
your local repository consists of three Trees maintained by git.The frst
one is
.Working !irectory
which holds the actual fles
The second one is
. n"e#
which acts as a staging area and fnally the third one is
. $%&!
which points to the last commit you have made.
4. To add and Commit
You can propose changes(add it to the index) using
git add !lename which we need to add"
git add #
This is the rst step in the basic git work!ow"To actually commit these
changes use
git commit $m %message for commit&
#ow the le is committed to the $%&' but not in your remote repository
yet"
'.To (ushing changes into remote repository
Your changes are now in the $%&' o( your local working copy"To send
those changes to your remote repository)execute
git push origin master
Changes master to whatever branch you want to connect your repository
to a remote server)you need to add it with
git remote add origin ser)er"
#ow you are able to push your changes to the selected remote server
*. To +pdate and ,erge
to update your local repository to the newest commit) execute
get pull
in your working directory to fetch and merge remote changes"to merge
another branch into your active branch (e"g" master)) use
git merge -ranch"
in both cases git tries to auto*merge changes" +n(ortunately) this is not
always possible and results in conficts" You are responsible to merge
those conficts manually by editing the les shown by git" &(ter changing)
you need to mark them as merged with
git add !lename"
be(ore merging changes) you can also preview them by using
git di. source/-ranch" target/-ranch"
0. To replace local changes
,n case you did something wrong (which (or sure never happens -) you can
replace local changes using the command
git checkout 1 !lename"this replaces the changes in your working
tree with the last content in $%&'" Changes already added to the index)
as well as new les) will be kept",( you instead want to drop all your local
changes and commits) (etch the latest history (rom the server and point
your local master branch at it like this
git fetch origin
git reset 1hard origin2master
3. To see log
in its simplest (orm )you can study repository history using
git log
you can add a lot o( parameters to make the log look like what
you want "To see only the commits o( a certain author use
git log 1author4-o-
To see a very compressed log where each commit is one line
use
git log 1pretty4oneline
.r may be you want to see an &/C,, art tree o( all
branches)decorated with the names o( tags and branches
git log 1graph 1oneline 1decorate 1all
To see only which les have changed
git log 1name$status

Das könnte Ihnen auch gefallen