Followers

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 ( https://gitlab.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


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. (ReadMe.md 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 bal.java in local repo and push it to remote repo.

     touch bal.java

     git add bal.java

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

     git push origin master

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


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

     Create a file db.java in Gitlab repo

     git pull origin master


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

         echo "New lines have been added by master" >> dao.java

         git status

         git add dao.java

         git commit -m "dao.java file is modifed"

        git push origin master


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,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Git Workflow Commands -Example
Git Workflow Commands -Example
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjW7WCknAvmyjPcZaU68yf5gD-PFIg0oNE2Ax8Gm5eYJZF8CojUWBYoqn992FusEtz7fnwHkTfPT4eNAW6aomAkzRUoNVAubAXwpcJ-QQD7HJCj-0JUDmjafOndbx6Xt8wcrTLEgCcOcKoksYxHhopS71xqNkQZHaW9RU7vis2uSGUk0aO0jS0MF-Iu/w393-h129/Screenshot%202022-02-08%20134232.jpg
DevOpsWorld
https://www.devopsworld.co.in/2022/02/git-workflow-commands-example.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/02/git-workflow-commands-example.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