Github Oveview
1. A Version Control System
2.A Publishing Tool
3.A Collaboration Platform
Benefits
- Great way to keep track of our codebase
- A way to share and collaborate with others
- Ability to save our process and go back to earlier points in our projects
- Github makes it difficult to "mess up" our projects
Step1: Create a new repository
Quick setup — if you’ve done this kind of thing before
git@github.com:psmaxwell/awesome_golang_project1_the_go_programming_language.git
or create a new repository on the command line
echo "# awesome_golang_project1_the_go_programming_language" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:psmaxwell/awesome_golang_project1_the_go_programming_language.git
git push -u origin main
or push an existing repository from the command line
git remote add origin git@github.com:psmaxwell/awesome_golang_project1_the_go_programming_language.git
git branch -M main
git push -u origin main
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
Step2: Open the Terminal, and then clone remote repository.
root@oracle-db-19c golang_projects]# git clone git@github.com:psmaxwell/awesome_golang_project1_the_go_programming_language.git
Cloning into 'awesome_golang_project1_the_go_programming_language'...
Enter passphrase for key '/root/.ssh/id_rsa':
warning: You appear to have cloned an empty repository.
[root@oracle-db-19c golang_projects]# ls -ltr
total 4
drwxrwxr-x. 16 maxwell maxwell 4096 Jan 15 14:44 maxwell_the_go_programming_language_projects
drwxr-xr-x. 3 root root 18 Jan 15 17:36 awesome_golang_project1_the_go_programming_language
[root@oracle-db-19c golang_projects]
Step3: Set your local project as the current working directory.
Step4: Initialize the local directory as a Git repository.
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]# git init
Reinitialized existing Git repository in /home/maxwell/projects/golang_projects/awesome_golang_project1_the_go_programming_language/.git/
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]#
Step 5: Add the files in your new local repository. Your files will now be staged for their first commit.
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]# ls -ltr
total 0
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:41 chapter2_program_structure
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:42 chapter3_basic_data_types
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:42 chapter4_composite_types
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:42 chapter5_functions
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:43 chapter6_methods
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:43 chapter7_interfaces
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:44 chapter8_goroutimes
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:44 chapter9_concurrency_with_shared_variables
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:44 chapter10_packages_and_the_go_tool
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:44 chapter11_testing
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:44 chapter12_reflection
drwxrwxr-x. 2 maxwell maxwell 6 Jan 15 14:44 chapter13_low_level_programming
drwxrwxr-x. 2 maxwell maxwell 60 Jan 15 16:14 chapter1_tutorial
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]# git add .
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]# git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: chapter1_tutorial/helloworld
new file: chapter1_tutorial/helloworld.go
new file: chapter1_tutorial/test.go
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]#
Step 6: Commit the files that you have staged in your local repository.
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]# git commit -m "First commit for hello world in Go"
[main (root-commit) 5e2d753] First commit for hello world in Go
3 files changed, 14 insertions(+)
create mode 100755 chapter1_tutorial/helloworld
create mode 100644 chapter1_tutorial/helloworld.go
create mode 100644 chapter1_tutorial/test.go
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]#
Step7:Push the sources code where your local repository into the remote repository.
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]# git push
Enter passphrase for key '/root/.ssh/id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 1.03 MiB | 3.29 MiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:psmaxwell/awesome_golang_project1_the_go_programming_language.git
* [new branch] main -> main
[root@oracle-db-19c awesome_golang_project1_the_go_programming_language]#