Git Workflow Commands -Example

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

 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 Lab (

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 (,,

             cd SpringBootMicroservices


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 raman

              git config --local

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 file to the stage area

           git add

           git status

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

           git rm --cached

           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 file in the local repo.

           git commit -m " is added"

           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

Step 13: - Create a private Repo in Gitlab

Step 14: Add remote repo reference to your local repository.

git remote add origin <<https url of your gitlab repo>>

Step 15: - Check .git/config file you should find a remote login entry.

   cat .git/config

Step 16: - Before pushing the local repo's data to remote repo, you should have all the files which are in the remote repo to your local repo. ( file is not in local repo).

    git branch --set-upstream-to=origin/main master

    git pull --rebase

Step 17:- Push all the files from the local repo to the remote repo. (By running the below command a master branch will be created in your Gitlab SpringBootMicroservice repo.

    git push origin master

Step 18:- To create a new file in local repo and push it to remote repo.


     git add

     git commit -m " file is added"

     git push origin master

and check on your remote repo file should exist in master branch.

Step 19:- Create a file in remote repo and pull it in local repo.

     Create a file in Gitlab repo

     git pull origin master

Step 20:- Modify file and push it to remote repo.

         echo "New lines have been added by master" >>

         git status

         git add

         git commit -m " file is modifed"

        git push origin master



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,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
DevOpsWorld: Git Workflow Commands -Example
Git Workflow Commands -Example
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