Friday, 13 March 2020

Use of Git and GitHub for software development (the basics)

 
Visual Code interface with Git plugin integrated.


Assumes Git is installed via: https://git-scm.com/downloads and that you have an account at https://github.com/



Clone an online GitHub repository to local machine

Open "Git Bash" and navigate to the directory where you would like to save the repository locally. Type:

git clone https://github.com/<USERNAME>/test_repo.git
This will clone the repository to your local machine:
Cloning into 'test_repo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 592 bytes | 5.00 KiB/s, done.




Edit a file and then commit changes to the GitHub repository

E.g. On your local machine edit the contents of README.md. Then using Git Bash type:

git add README.md

git commit -am "commit message" 

git push



Adding existing local project/package to Github

Create a new repository on GitHub e.g. "test_repo" and make it Private
To avoid errors, do not initialize the new repository with README, license, or gitignore files.
You can add these files after your project has been pushed to GitHub.

git init

git add .

git commit -m "First commit" 
At the top of your GitHub repository's Quick Setup page, click to copy the remote repository (https) URL.

git remote add origin https://github.com/<USERNAME>/test_repo.git

git remote -v

git push origin master
 

Git configuration for use with proxy - Optional

Open "Git Bash" shell program (installed as part of Git) and type:

git config --global http.proxy http://USERNAME:PASSWORD@PROXYADDRESS:PROXYPORT
git config --global https.proxy http://USERNAME:PASSWORD@PROXYADDRESS:PROXYPORT
 

No comments:

Post a Comment