Git workflow¶
While the workflow will wary depending on your exact requirements, this is a reasonable starting point.
Workflow - your Git repo¶
This example uses GitHub, but the differences are small between the remote Git repositories and most will be the same if you are using GitLab, Gitea, etc.
Preparations - once¶
GitHub (or similar) accounts and SSH keys - once¶
- Create an account at your chosen Git repository platform, in this example GitHub.
- Create SSH keys at upload/add them SSH keys
Create a repository locally (or on GitHub) and prepare it - once per repository¶
Here we create it locally.
- Create a project folder or navigate to an existing one:
- Initialize Git (create a .git folder and starts tracking everything within your project folder):
- Add/create once or more files. One of them should preferrably be
README.mdwith info about the repository. - Stage and commit the file(s):
If you want to add all modified and new files in the current directory and below it, you can use (be careful):
Check with
git logthat all was added and committed. - Create a repository on GitHub
- Click the
+and selectNew repository. - Name it the same as your local project folder. (Here,
myproject). - Do not choose to initialize it with a readme - you are using the file in your local project!
- Click “Create repository”
- Click the
- You now want to push the local project to GitHub for the first time for the repo. Do this locally (change to your own username):
- It is now setup. You should also add a
.gitignorewith file types and directories you do not want Git to track. Add, commit, and push. - Create reasonable directories:
mkdir scripts results data - Add some initial text to a file in each directory. Add, commit, push.
Work with your project - regularly/each time you added something¶
- Are you collaborating with someone who may add to the repository? Do you, yourself, work on it on more than one computer? If yes, ALWAYS start with
git pull --rebasebefore you start working for the day. - Work on your project. Add/modify files.
-
- Check with
git statusif you have something that is not added/committed. - If so,
git add FILE(S),git commit -m "Write a good commit message so you can later recognize what is in this change" - Do
git pull --rebasein case others have updated something while you worked. - Then do
git push
- Check with