Git and GitHub – How to push/pull and clone files between Local machine and GitHub (Part-8)

Pushing Existing Code to GitHub using HTTPS

Prerequisites:

  • Git must be installed on your local machine.
  • A GitHub account.
  • An existing project on your local machine.

Run below command

git push https://github.com/AzureDevops-demoproject/Git_demo.git master

It will ask for personal token to connect to github

Create personal token from github

Go to profile –> Setting –> developer setting

Developer setting –>personal access tokens–> Tokens /(classic)–> generate new token

Now we can go and check the repository

File push to github repository

How to clone from github to local machine

 git clone https://github.com/AzureDevops-demoproject/Git_demo.git

Next create ,modify the code, git add, commit follow below steps

78  touch file3
   79  git status
   80  git config user.name :"RAj"
   81  git config user.email "usus@gmail.com"
   82  git add
   83  git add --all
   84  git status
   85  git commit -m"adding other user"
   86  git status
   87  git log
   88  git push origin master

now push back to github (remote location)

git push origin master (if you done clone and can use origin instead of long url)

or

git push https://github.com/AzureDevops-demoproject/Git_demo.git master

or

check repository now

Now other want to pull it

use below command

Use below so can use origin in future instead of long url

git remote add origin https://github.com/AzureDevops-demoproject/Git_demo.git

Now use

git pull origin master

Now, Sync the local repository as remote repository

Now using SSH

First need to generate SSH key using below

ssh-keygen

Copy public key in github

where to copy in github –> go to profile –> setting–> SSH and GPC key –> new ssh key — add public and save it

Use ssh link same way as we doing for https:

git@github.com:AzureDevops-demoproject/Git_demo.git

Related Posts

Git and GitHub – GitHub Overview (Part-15)

1. Github Description: 2. Org (Organization) Description: Example: 3. Team Description: Example: 4. Auth (Authentication) Description: Examples: OAuth Authentication: Personal Access Tokens: SSH Key Authentication: 5. Action…

Read More

Git and GitHub – Git Log Explanation (Part-14)

Git Log Explanation Explanation of Each Part 1. Commit Hash 2. References (Branches and Tags) 3. Commit Message Simplified Breakdown of Each Line Summary The git log…

Read More

Git and GitHub – Merge and Pull (Part-13)

Merge and Pull in Git Merge Merge is a command used to combine the changes from one branch into another. It is typically used to integrate changes…

Read More

Git and GitHub – Types of branch (Part-12)

Local and Remote Branches in Git Local Branch A local branch is a branch that exists in your local Git repository. You create and manage local branches…

Read More

Git and GitHub – Git Undoing, Conflict Resolution, Cherry Picking, Stash (Part-11)

Undoing changes in Git can be approached in several ways, depending on what you need to achieve. Here, we’ll cover the most common scenarios and commands for…

Read More

Git and GitHub – Understanding Git Concepts (Part-10)

Understanding Git Concepts 1. Git Branching and Merging Branching allows you to create a separate line of development. It’s useful for working on different features or fixes…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x