Closed github-actions[bot] closed 2 months ago
Push the branch to origin and create a pull request (PR)
Should you rebase first?
Should you squash the commits on the branch into just one on main?
When the changes have arrived on main, should you then delete the development branch?
First let's install a handful of really useful extensions. Find and install all of the following (some of them may already be installed, in that case just verify that they are installed):
All-right enough for now. You can explore all of these extensions on your own hand, for now just pay attention to
autopep8
- the auto formatter. In the documentation to the extension it instructs you how to enabled it in yoursettings.json
file:Set that up.
Lets take everything that's Python related (Python, Pylance, Python Debugger and autopep8) add it to the devcontainer - simple right-click on the extension and from the context menu choose add to devcontainer.json. We do this because we want every team member to have the same off-set condition when we collaborate.
Some of these extension are more convenient tahn strictly necessary, but they only work in containerized environments if they are installed inside the container. That's true for Phind and Git Graph so add them too, in the same way.
In you
.devcontainer/devcontainer.json
file you end op with a customizations section something like this:Rebuild your container and see that it works.
As before run git
add
,commit
andpush
. Remember to mention the Issue number in the commit message.For the remainder of the extensions (GitHub Copilot, GitHub Copilot Chat and GitHub Pull Requests) they are also merely convenient and not strictly required, so you can and them by syncing them with your user:
Right-click on each of them, one at a time, but instead of adding them to the container you mark Sync This Extension - provided that you are logged into VS Code.
Different languages and technologies creates different output's from builds, temp files, caches etc. Theses files are referred to as derived objects and they are seldom considered configuration objects meaning they should not be version controlled - at least not in git.
This is why your project needs a
.gitignore
file - which specifically tells git which files to ignore.But before you continue with creating the
.gitignore
file, setup a development branch dedicated to this issue #2 and commit the changes we have done so far.Hint on how to create a branch dedicated to an issue
You have at least three obvious ways to do this - here are som pointers: - [Use the Git Pull Request extension in VS Code](https://code.visualstudio.com/blogs/2020/05/06/github-issues-integration#_working-on-issues). - [Do it from the issue on the GitHub web](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-a-branch-for-an-issue) - [Do it from the command line using the `gh issue develop` CLI](https://cli.github.com/manual/gh_issue_develop)The GitHub community jointly maintains these
.gitignore
files for each specific language and technology. Have a look at the github/gitignore repo and see if you can finde something useful in context of Python.Create a file in the root of your repo named
.gitignore
. copy and paste the raw content of the file you found into it.Spoiler
[`Python.gitignore`](https://github.com/github/gitignore/blob/main/Python.gitignore) You can see the file in it's _raw_ mode and copy the content from there using clip board, or you can simply copy it over from it's location on git and into your repo by running this command in your terminal to download it: ```shell curl -L https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore >.gitignore ```Then git
add
,commit
remember a clever commit message - you can leave out thepush
until we're all done with this issue.You have already come very far on your DevX setup, but let's add just one more nice feature:
Create a
.gitconfig
file in the root of your repository and copy the following context into it:The file represents some specific git settings - we can always add more, for now we just want to mimic that that we're working in a team, and we would like the team to jointly adhere to the same how-we-work standard. and that incudes that we're using git in the same way.
To get this into play, let's ask the devcontainer to add it as part of the
postCreateCommand
The
postCreateCommand
in thedevcontainer.json
file is designed to only tun one command. So a convention is simply to have it runt apostCreateCommand.sh
script - and then add whatever you need to that script.Let's first create a script
.devcontainer/postcreate.sh
Like this:
To make the script executable we will need to set the execution bit. From the terminal run:
Last change we need is in the is in the
.devcontainer/devcontainer.json
file itself.You will probably find a line that is commented out, which starts with
"postCreateCommand":...
Change that line to read
Done! do your final git
add
,commit
again - remeber a clever commit message and leave out thepush
for now.Now you have a branch - related to a specific issue - that has more than one commit. Consider your options:
origin
and create a pull request (PR)?main
here in this repo and then only pushmain
main
main
should you then delete thedevelopment branch
origin
There's no right or wrong all choices to these different options are valid and common. Make a choice - and argue your case.