Working with Version Control
Table of contents
Pull from Existing Repository
As you learn how to code, you soon realize that there will be a lot of group coding involved. As such, it is important to be aware of certain practices when it comes to version control. One of them happens to be “Pull first, make changes and commit later”. Therefore, we will go over how to pull first before we get to committing and pushing changes.
Steps
Press the update project button.
Check off Merge incoming changes into the current branch then press ok.
Recommended
"Rebase the current branch on top of incoming changes" will also integrate changes from one branch to another. However, rebasing can be dangerous because it can "rewrite history" of shared branches. Therefore, it is better to _Merge incoming changes_ instead.
Congratulations! You should see a pop-up that indicates successful project update.
Committing and Pushing Changes
We have all experienced losing our saved work whether by forgetting where we have put them or messing up so bad the file got corrupted. It is also important to save your work when coding as well. To do that, you need to commit the changes you have made and push the changes to the repository you have cloned.
Steps
If you see your files change colour as highlighted below, it means there are changes made that is not saved.
As highlighted below, you will see 3 shapes on the top right of your PyCharm.
Press the Check-mark shape to commit.
Check the files you want to save.
Fill out the changes you have made to those files.
Simple descriptions that others can understand what changes you have made are best.
CAUTION
You may choose to press "commit" here to simply commit the changes you have made. However, in order to SAVE the changes you have made to a repository that you cloned from, you must also "push" the changes you made as well. The next step will entail "pushing" changes.
Press the downward arrow next to commit button.
You will be led to a new window detailing what will be pushed.
Press commit and push and then push.
Congratulations! You committed and pushed the changes you made to the files!
Recommended
It is a good practice to commit and push often;
Committing and pushing after coding a function is ideal.
Side-note
CAUTION
If you have run into this error above, it means the repository has changes that your local files have not received yet. You can press Merge here to push and update your current files. However, it is good practice to pull first before committing and pushing.