git with github

 Scenario 1:

--------------------------------


***Suppose I have a GitHub account and I want to connect that account's project and repository with my local git bash so that I can push the codes to the GitHub or can take pull also.

connect git bash to your GitHub repository

First I will log in to my GitHub account.

There I will create a project and a repository inside that project.

I will copy that repository link.

Let my repository link is github_repository_link


Now, let I want to make a local project directory where I can save my work and will push my code to GitHub or take a git pull.

Let it is in D drive --> Java --> codes


I will be inside the D drive --> Java --> codes folder and 

right-click there --> choose option  "GIT bash here"





Now the git bash edited will be opened where we will write the command to connect to git hub account...


Command :

-----------------------------------

$ git remote add origin  github_repository_link


Where to find the GitHub link?






To check what we can do with that connected repo use the command :

$ git remote -v


Add files stage area for git push and commit

$ git add .



**Git commit 

$ git commit -m "Second commit"




**Push (local)files to (remote)GitHub through gitbash command

$ git push origin master




Now git will ask you to log in to your GitHub account.

Do login and upload will be done to your GitHub.



Creating a new branch and store data in that

$git checkout new-branch


***Now we will be switched to the new branch.

***now use $git add filename 

***to add your files to the newly created branch and follow the same steps to push them to the branch after commit.


After saving those work now I want to merge that file to the master branch.

How to do that?




command :


1.First switch to master branch ...

$git checkout master


2.Now use merge command :

$git merge new-branch


//Master is the master branch and origin is the server which same for all git


















#git

#github

#agile

#repository

#gitrepository

#remoteRepository

#push

#gitpush

#gitpull

Comments

Popular posts from this blog

Git Commands With Output Log

Java Interview Preparation (conceptual)

Java 8 Function Interface