-
Notifications
You must be signed in to change notification settings - Fork 1
Git workflow
Whenever you want to start working on something new, first make sure you are on the main branch. ("git checkout main" to get there if you aren't). Type "git pull" to make sure you are up to date, then you can create a new branch.
git checkout -b new-feature
^
This creates a new branch titled new-feature
After youve made changes:
git add .
^
This adds all changed files to the staging area
git commit -m "description-of-what-was-added"
^
This creates a commit with the message "description-of-what-was-added"
Then push to the remote branch (ie github repo). Up to this point, the branch you have been working on is only on your local machine.
git push -u origin new-feature
^
This pushes your branch (here new-feature is whatever your branch is named) to the origin (the github repo)
In the output of the git push command there will be a link to create a merge request. Go to this link. Click create pull request. That will take you to another page. Here it will tell you whether or not there are any merge conflicts. If there are none go ahead and merge! Once you've merged successfully click delete branch!
When you navigate back to your local repo, you will still be on the branch that you created, to get back to the main branch, type "git checkout main". Then you can type "git branch -d new-feature" to delete the branch from your local repo (this is not necessary but it is good to delete it because it is not needed). Now your local main branch will be behind the github repo because you have not pulled the changes that you pushed up. Make sure to always pull before you make a new branch to ensure that you are up to date with all other changes. You can do "git status" to see if you are behind
I know this is a bit complex but it will help prevent us from having bad merge conflicts and this is how you will use git in your jobs so its good experience! If you have any questions don't hesitate to reach out. I'm still learning as well but I will help in any way I can!
Here is a link to a video demonstrating the process: https://youtu.be/lOF8R0EzYUM