Last active
November 17, 2023 09:00
-
-
Save juanonsoftware/acdaccf00fda14ca8613c5abc0a4b18d to your computer and use it in GitHub Desktop.
Poc GIT workflows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create a git repo https://github.com/juanonsoftware/PocGitWorkflows | |
2. In Windows, create a folder D:\Dev\PocGitWorkflows | |
3. Open the Terminal and do the following on that folder: | |
- git init -> to init an empty git repo | |
- create a txt file called Readme.txt | |
- git add -A -> to add all changes from tracked / untracked files | |
- git commit -m "First commit in the repo" -> commit for the first time | |
- git remote add origin https://github.com/juanonsoftware/PocGitWorkflows.git -> to add a remote | |
-> git push -u origin master -> to push the local branch to remote repo | |
3. Now refresh https://github.com/juanonsoftware/PocGitWorkflows to see the new file available on github | |
4. Create new branch | |
- git checkout -b Feature-01 -> create new branch and switch to Feature-01 | |
- git branch -v or git branch -l -> to verify which branch we are | |
5. Add a new file Feature-01\F01.txt | |
- git add . -> to track the new file | |
- git commit -m "Feature 01" -> commit the feature 01 | |
6. Push the new branch to remote | |
- git push -u origin Feature-01 > to push new branch (-u to add remote tracking branch) | |
7. Now refresh the repo to see new file & new branch | |
8. Now update the feature-01's file, then add/commit/push | |
- git add . -> to track the change | |
- git commit -m "Feature 01 - Updated 01" -> commit the change | |
- git push -> push the change, without giving remote branch (because -u added last run) | |
9. Now refresh the repo to see new file updated | |
10. Create a new pull request | |
- Create a new pull request bases on master and the branch | |
- Then other member can review / comment on it | |
11. Merge the feature | |
- This can be done by UI (to merge the request) | |
- git checkout master -> to switch to the master branch | |
- git pull origin Feature-01 -> pull and merge | |
- git push -> push the change to repo | |
12. Now create a new branch Feature-02 | |
- git branch Feature-02 -> to create new branch | |
- git checkout Feature-02 -> to switch to the new branch | |
13. Create new folder Feature-02 and adding new file F02.txt | |
- git add . -> to add all changes | |
- git commit -m "Feature 02" -> to commit | |
- git push -u origin Feature-02 -> to push to remote repo | |
14. Edit Readme file | |
- git add . -> to add all changes | |
- git commit -m "Update readme to add progress of F02" -> commit the change | |
- git push -> to push to remote repo | |
15. Now merge to the master (no pull request) | |
- git checkout master -> switch to the master | |
- git pull -> to get the latest | |
- git merge Feature-02 -> to merge with Feature-02 branch | |
- git push -> to push changes to the remote repo | |
16. To create a tag | |
- git tag -m "Feature-02 implemented" v1.0.2023.11141018 -> create a new tag on current commit | |
- git tag -l -> to see all tags | |
- git push origin v1.0.2023.11141018 -> to push the tag to remote repo | |
17. To delete a branch | |
- git branch -d Feature-01 -> Delete the branch in local | |
- git push origin :Feature-01 -> to delete the branch on remote | |
- git push origin --delete Feature-01 -> another way to delete the branch on remote | |
18. Delete the branch Feature-02 | |
- git branch -d Feature-02 -> Delete local | |
- git push origin --delete Feature-02 -> Delete on remote | |
19. Git merge with --no-ff -> to keep history of the branch if the HEAD is accessor of the new branch | |
- git checkout -b FeatureZ -> create new branch then made some update | |
- git add . -> track the changes | |
- git commit -m "Commit for Feature Z" -> commit the changes | |
- git push -u origin FeatureZ -> push the changes to remote repo | |
- git checkout master -> switch to master branch | |
- git merge --no-ff FeatureZ -> merge with FeatureX branch with no-ff | |
- git push -> push the master. Now we see FeatureX is in the history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now using git flow https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
Create a branch named develop
Init the flow, follow all selections
git flow init
Switch to develop branch
git switch develop
Now push the branch to remote
git push --set-upstream origin develop
6. Create a new release branch:
git flow release start 1.1.0
-> Now checking which branch we are (it is release/1.1.0)
git branch
-> Work on the new branch as usual
7. Finish the release by running below command:
git flow release finish '1.1.0'
-> this will merge the release back to develop/master, create a tag
Summary of actions:
8. Create a new hotfix branch
git flow hotfix start hotfix_branch
Summary of actions:
9. Finish the hotfix
git flow hotfix finish hotfix_branch
Summary of actions: