Followers

Git Workflow commands with Github

    Below is the example for git workflow and it shows the different stages with git commands to manage local and global repositories (I am ...

  Below is the example for git workflow and it shows the different stages with git commands to manage local and global repositories (I am using Git Lab but you can use Github also)

Local Repo:- git 

Remote Repo:- Git Hub ( https://github.com)

Consider You are a developer and working on a java project and the name of the project is SpringBootMicroservice. In this project, there are a couple of files ( I am creating some dummy files with extension .java). This project is running on a development box so You need to set up local configuration file ( with your name as Author and your email as email)

Step 1:- Create folder SpringBootMicroservice which has my project files.

             mkdir SpringBootMicroservice

Step 2: - Create required files ( restapi.java,dao.java,services.java)

             cd SpringBootMicroservices

             touch restapi.java dao.java services.java

Step 3: - Initialize this project with git init command

               git init

Step 4: - Check that there must be a .git directory get created which is responsible for managing this project's repo.

               ls -la

               ls .git

Step 5: - Setup the Author name and Author's Email address for this project locally.

              git config --local user.name raman

              git config --local user.email raman@gmail.com

Step 6:- Verify in .git/config file that the author name and email address is properly configured

            cat .git/config

Step 7: - Check the local repository status.(all 3 files should be untracked)

           git status

Step 8:- Push dao.java file to the stage area

           git add dao.java

           git status

Step 9:- Unstaged (moving stage to untracked) dao.java file

           git rm --cached dao.java

           git status

Step 10:- Push all the files in the stage area.

          git add .   # or you can use git add -a

          git status

Step 11:- Commit dao.java file in the local repo.

           git commit -m "dao.java is added" dao.java

           git log

Step 12: - Commit all the files in the local repo.

          git commit -m " restapi and services java files are added"

          git status

          git log 

          git log --oneline


Github Repository


Step 1: Create new Repository in Github.

            Goto Github.com and log in with your credentials.

Step 2: Click on New button or click on Start project button

Step 3: Provide following information for the Git Repo

           Repository name: SpringBootMicrroservice

           Select Public radio button

         Click on Create Repository

Step 4: Create token in Github

           Select Settings from the account.

           Select Developer Settings

           Click on Personal Access token

           Click on Generate new Token

           Provide following information

                 Note: token1

                 Expiration: 7 days

                 tick mark :- repo, admin.org 

           click on Generate token

           and note down the token number

Step 4: Click on HTTPS and copy the HTTPS URL

Step 5: Run below set of commands to push the code from local repo to Github Repo

           git branch -M main

           git remote add origin <<HTTPS URL>>

           git push origin main

           provide user name as Github username and password as token value

Step 6: Verify the main branch gets created on the Github and all the files of the local repo are available on the Github repo.


Connect local git repo with Github using SSH keys

Step 1: Create ssh keys on the local system

            ssh-keygen

            copy the content of /root/.ssh/id_rsa.pub file

Step 2: Goto Github Repo -->Settings --> Deploykeys

          Click on Add key button and paste the content of the ssh key

          Click on Allow write Access check box.

          Click on Add key button

Step 3: Copy the ssh URL of your Github repo.

Step 4: vi .git/config

     in [remote origin]

   replace URL with the ssh URL of your Github repo.

Step 5: Create a new file in your local repo and push it to the Github Repo.

      touch bal.java

       git add bal.java

       git commit -m "bal.java file is added"

Step 6: Push the local Repo to Github repo

      git push origin main













COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,3,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Git Workflow commands with Github
Git Workflow commands with Github
DevOpsWorld
https://www.devopsworld.co.in/2022/04/git-workflow-with-github.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/04/git-workflow-with-github.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content