Git
Using git
Creating a local repository
- create a new folder
mkdir hello-git
cd hello-git
- intialize git repo
git init
- this creates a new folder
.git - lets know the status
git status
- now create a new file and check status
git status
* Now lets add the changes to staging area and view the status
git add <filename|directory>
git status
* Now lets commit changes. A git commit requires
* username (set it once)
* email id (set it once)
* commit message (pass as argument)
* date time (we need not pass)
* Lets set username and email id
git config --global user.name "shaikkhajaibrahim"
git config --global user.email "shaikkhajaibrahim@gmail.com"
- Lets commit the changes
git commit -m "First Commit"
* lets view git history
git log
- Git deals with changes not individual files
- In working tree we will have two types of files
- tracked
- untracked (never has been part of git history)
- Now lets make one more change and add a commit.
git status
* commit the changes
git commit -m "Second commit"
- View commits as graph
Tips for git command line
- Use help/manual
--help - Use cheatsheet Refer Here
- use the following prompt
Act as git and I will be entering git commands tell me what the command does , Ensure you give necessary explanations and examples.
