Github is a git repository hosting service. As a user,
you can place all your data in github repositories and access it from anywhere.
In this post, you are going to learn.
a.
How to create an account in github
b.
How to create and push the local git
repository to github
How to create an account in github?
Go to 'https://github.com/' and create an account.
How to create and push the local git repository to github
When you login to github.com, you can see below kind of
screen.
At left side of the screen, you can see all your
repositories. Click on 'New' button to create new repository.
Give the Repository name as ‘gitHelloWorld’ and select
the checkbox 'Initialize this repository with a README' and click on ‘Create
repository’ button.
‘gitHelloWorld’ repository is created for you.
How to clone and push the changes to github repository
Step 1: Create a directory ‘HelloWorld’.
Step 2: Navigate to ‘HelloWorld’ directory and
clone the git repository.
You can get the clone url from ‘Clone or download’
button.
Step 3: Execute below command to clone the git
repository.
git clone {REPOSITORY_URL}
Example
$git clone https://github.com/harikrishna553/gitHelloWorld.git Cloning into 'gitHelloWorld'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. $ $ls gitHelloWorld $tree . └── gitHelloWorld └── README.md 1 directory, 1 file
Step 4: go to the folder ‘gitHelloWorld’ and add
a file ‘welcome.txt’.
$cd gitHelloWorld/ $ $touch welcome.txt $ $git status On branch master Your branch is up to date with 'origin/master'. Untracked files: (use "git add <file>..." to include in what will be committed) welcome.txt nothing added to commit but untracked files present (use "git add" to track)
As you see the output of the command ‘git status’, you
can observe welcome.txt is untracked by git.
Let’s add this file to git repository by executing below
command.
git add welcome.txt
$git add welcome.txt $ $git status On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: welcome.txt
Step 5: Commit the file welcome.txt by
executing below command.
$git commit -m "Adding welcome.txt to the repository" [master 70d8ded] Adding welcome.txt to the repository 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 welcome.txt
Step 6: Push the changes to remote repository
by executing below command.
git push origin HEAD
$git push origin HEAD Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 12 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 308 bytes | 308.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/harikrishna553/gitHelloWorld.git e7e1088..70d8ded HEAD -> master
Go to gitHelloWorld repository from github.com, you can
see the new file welcome.txt.
No comments:
Post a Comment