Git command line
Three states
-Working directory
-staging area - pre- commit holding area
-Commit - git repository(history) .git folder
branch - time line of your changes
main site https://github.com/
Git command line
Three states
- Working directory
- staging area - pre- commit holding area
- Commit - git repository(history)
branch - time line of your changes
git version
git config --global user.name "your usernanme"
git config --global user.email "user@mail.com"
check configs
git config --global --list
Further you can check these in the file system in ".gitconfig" file inside user directory
eg: C:\Users\{username}\.gitconfig
It will contain something like below
--------------------------------------------------------------------------
[user]
name = Amal
email = aprasad@vsa.com
clone repository. create a folder to pull and execute clone command
git clone https://yourrepourl/demo.git
Now you have clone the repository.go to repository working directory and get status
git status
this will tell your branch and upto date status.
eg: 'origin\master' - virtual reference to repository
This will check changes against
1. working directory
2. staging
3. local repository
4. remote repository
Note: working directory, staging, local repository are in Local and only remote repository lies outside.
Now add a new file "start.txt" for your working directory and see the status
it will show you that there is an untracked file
Remember file is still in "working directory"
you need to "add" to repository
git add start.txt
if you check "status' it will show you a new file: start.txt with the messaage "Changes to be committed. "
Now file is in "Staging" area. Staging area let's keep multiple files and let you commit as a single unit.
Now you can commit using
git commit -m "your message to commit"
Now if you check status, git will tell - nothing to commit, working directory clean.
Now new file is moved from "staging area" to "Local repository" (.git folder)
we have still not pushed to Remote. if you go to remote repository via browser, you will see no changes.
git push origin master
origin - refers to the Github copy of your/our repository
master - refers to default and only branch
This will prompt for username and password
Now if you browse the Github repo , you will be able to see the newly pushed file.
Following commands may useful creating and go through files
pwd
mkdir projects
cd projects
pwd
Below is the summary of basic commands
git version
git config --global user.name "Alex Baar"
git config --global user.email "albe@git.training"
git config --global --list
git clone github-https-url # paste in your GitHub HTTPS clone URL
ls
cd github-demo
ls
git status
echo "Test Git Quick Start demo" >> start.txt
ls
cat start.txt
git status
git add start.txt
git status
git commit -m "Adding start text file"
git status
git push origin master
No comments:
Post a Comment