Add Local Repository to BitBucket/GitHub

By Technical Digit
  • Create an account on BitBucket/GitHub.
  • Create new respository in BitBucket/GitHub. And you will get a http clone url with .git extension as below.
    git clone https://github.com/user_name/myrepository.git
  • Next go to your local project/directory in Git Bash Terminal.

cd /path_to_local_folder/repo

  • Init your project as git repository

git init

  • Connect your local repository to remote git repository. [Change below link as per your remote git repository.]

git remote add origin https://github.com/user_name/myrepository.git

  • Add all your local files of project to git version control system

git add .

  • Commit all changes with a message

git commit -m ‘My First Commit to Git’

  • Upload/Push your local files to remote git repository.

git push -u origin master

  • It will ask for password for your BitBucket/GitHub Account. Enter it.
  • Now go to your remote git repository and check all local files will be there. That’s All Done !!
Other Useful Commands for Git:-

# Create a new branch

$ git branch

# List all remote or local branches

$ git branch -a

# Delete a branch

$ git branch -d

# Checkout an existing branch

$ git checkout

# Checkout and create a new branch with that name

$ git checkout -b

# Merge changes into current branch 

$ git merge

#Create a local working copy of an existing remote repository

$ git clone

#get the latest version of a repository

$ git pull <remote_URL/remote_name>

#Sends local commits to the remote repository

$ git push —all

Total Views: 1780