DevOps Tools/SCM/Git
From r00tedvw.com wiki
(Difference between revisions)
Line 13: | Line 13: | ||
~$ git init ~/repo | ~$ git init ~/repo | ||
Initialized empty Git repository in /home/user/repo/.git/</nowiki> | Initialized empty Git repository in /home/user/repo/.git/</nowiki> | ||
+ | Set repo user & email, if you want something different from the global. | ||
+ | <nowiki>~$ git config user.name "user" | ||
+ | ~$ git config user.email "[email protected]"</nowiki> | ||
+ | =Commands= | ||
+ | ==add== | ||
+ | adds a new file to the repo. | ||
+ | <nowiki>~$ git add filename | ||
+ | ~$ git add * ---- adds everything in the current directory | ||
+ | ~$ git add . ---- adds everything in the current directory | ||
+ | </nowiki> | ||
+ | ==status== | ||
+ | shows the current status of the git repository | ||
+ | <nowiki>~$ git status</nowiki> | ||
+ | ==commit== | ||
+ | Commits the changes to the repo | ||
+ | <nowiki>~$ git commit -m "comment on commit"</nowiki> |
Revision as of 15:35, 19 June 2018
Overview | Source Control Management (SCM)
Git
Contents |
Install and Configure
Done on CentOS 7. Serves as an agentless server and client. You can use this package to create a local repository as well as other git functions.
~$ yum install git
Setup global parameters
~$ sudo git config --global user.name "global username" ~$ sudo git config --global user.email "email address" ~$ sudo git config --system core.editor "/bin/vim"
Initializing Local Repo
Create a local directory with nothing in it. This is called initializing the repository
~$ mkdir ~/repo ~$ git init ~/repo Initialized empty Git repository in /home/user/repo/.git/
Set repo user & email, if you want something different from the global.
~$ git config user.name "user" ~$ git config user.email "[email protected]"
Commands
add
adds a new file to the repo.
~$ git add filename ~$ git add * ---- adds everything in the current directory ~$ git add . ---- adds everything in the current directory
status
shows the current status of the git repository
~$ git status
commit
Commits the changes to the repo
~$ git commit -m "comment on commit"