DB-hub Technology 未分类 Git quick start

Git quick start

STEP1: Initialize git into your current working repository

mkdir sample
cd sample
git init

STEP2: Create a new remote, name it “origin”
– Adding the location of your remote repository where you wish to push/pull your files to/from

  • Your remote repository could be anywhere on github, gitlab, bitbucket, etc.

  • Here origin is an alias/alternate name for your remote repository so that you don’t have to type the entire path for remote every time and henceforth you are declaring that you will use this name(origin) to refer to your remote. This name could be anything.

  • To verify that the remote is set properly type : git remote -v

git remote add origin git@github.com:User/UserRepo.git

STEP 3:

create a branch, for Giblab, default is “main”

git branch -M main

pull from remote

git pull origin main

STEP 4:
add some files

echo "# MESSAGE" >> README.md
git add README.md
git commit -m "first commit"

STEP 5:

git push -u origin master
  • Pushes your files to the remote repository.Git has a concept of something known as a “branch”, so by default everything is pushed to the master branch unless explicitly specified an alternate branch.
  • To know about the list of all branches you have in your repository type :git branch

some commands:

# delete a branch
git push origin --delete <branch name>

#show all remote and local branches
git branch -a

Leave a Reply

您的邮箱地址不会被公开。 必填项已用 * 标注

Related Post