Git 101 to new users — from creating a new repo to push

Jingying Liu
4 min readOct 15, 2020

Github repo: https://github.com/jl4730/GitProLearning

This summer I have helped the tech team with some simple tech tickets. Through which I have some exposure to SDE’s work: daily standup, scrum master, Jira ticket, stash repo, etc. It’s a lot of fun. I want to take this chance to summarize some basic commands used to help someone who never had such experience. This is not for experienced developers as the information here is super basic.

Step 1: create a branch based on existing branches

Here is a graph showing the branches. We can see some recent work based on the develop branch committed by colleagues.

all branches graph from stash

Now we can create a branch based on develop too by clicking the left hand side icon:

After getting into the new branch, we need to get the SSH to be able to go on doing GIT CLONE later. The icon is again on the left-hand side.

Step 2: create a repo in the terminal using GIT commands

Firstly cd to the folder you want to put the branch into. Note the default folder changed to the desired place after the cd command.

Now git clone using the SSH from step 1. All the files on the branch will be downloaded to the local folder for you to develop.

Now we want to create a virtual environment used for our repo. The command is “virtualenv .venv”. You can use other names instead of .venv.

After creating the virtual environment, we need to activate it using “source .venv/bin/activate”. Note how the environment changed to .venv after activation.

Then we need to install packages into the virtual environment using “pip install -U -r requirements.txt”. The text file contains the package information needed for our repo to run smoothly.

Finally, we need to shift to the branch based on the base branch. “git branch” helps us check where we are, and “git checkout” helps us create and switch repos.

Now we are on our own repo and can start developing.

Step 3: developing and push the changes

I used PyCharm to open the folder created and make necessary changes based on the Jira ticket description. After you are comfortable with the changes made and make sure all test cases passed, you may go ahead push the changes and raise PR (pull request) for code reviews.

“git status” can help track the changes made. We can see there are two files modified.

We use “git add” to include the changes so they can be ready to be committed.

We use “git commit” to commit changes. The “-m” is adding comments so that we know what we are doing with the commit.

Finally, we can do “git push” to upload all the changes we make.

Now we can pull request so our dear co-workers can review the changes and comment on the code.

That’s the flow. Hope this helps.

--

--