Select Page

How to pull [clone repo] files from github repo to local git
how to pull files from local to repo

how to create branches and delete

**bold text**

### 1. Clone the repo

`git clone https://github.com/anj-bookwormhead/test12.git`

2. Authenticate your account

“`git config –global user.email [email protected]`
git config –global user.name anj-bookwormhead“`

### 3. initiliaze the files in from your local computer to github

“`echo “# test12” >> README.md
git init
“`

### 4. publish the files to github

poin the cli to the right directory.

“`git branch -M main “`
For the main – you can select which branch tag you want to add the files.

`git remote add origin https://github.com/anj-bookwormhead/test12.git`
git push -u origin main

Add a documents to cli to github

If you want to add all the files, use .
“`
git add .
git commit -m “2nd commit”
git push origin main
“`

If you want to add specific file.
“`
git add README.md
git add test2.txt
git commit -m “2nd commit”
“`

### …or use remote if the files are not cloone in github

git remote add origin https://github.com/anj-bookwormhead/angelic1241029.git
git branch -M main
git push -u origin main

_________________________________________________________

Option 2: Use this if the files are clone in github
IF you encounter an error

**$ git remote add origin https://github.com/anj-bookwormhead/test12.git
error: remote origin already exists.**

Check the if there’s a origin existing
$ git remote –verbose

origin https://github.com/anj-bookwormhead/test12.git (fetch)
origin https://github.com/anj-bookwormhead/test12.git (push)

git push https://github.com/anj-bookwormhead/test12.git

git remote set-url origin https://github.com/anj-bookwormhead/clonerepo2.git

## **Github** Branch

“` $ git branch -a“`

**Result example**

“`
* main
* new-branch
* old-branch
“`

**Delete local branch**

“git branch –delete or
“git branch -d mybranch

**Delete remote branch**
“git push origin –delete oldbranch“

It create and switch to the new branch you created
“git switch -c mybranch“

Just switch to other brand

“git switch main