So now let’s push the code to github repository. Before that there is some final checks need to be done from our end.
Check .gitignore file and update
โ
Files/Folders to Include in .gitignore
Hereโs a breakdown of which files/folders should be added to .gitignore in your Rails project:
These files are user-specific or environment-specific and should not be committed to Git.
1๏ธโฃ .dockerignore โ โ Ignore from .gitignore
- Keep this file if you’re using Docker.
- Itโs like
.gitignorebut for Docker, helping to reduce Docker image size. - Do not add it to
.gitignoreif you need it.
2๏ธโฃ .github/ โ โ
Add to .gitignore (If personal CI/CD configs)
- If this contains GitHub Actions or issue templates, keep it in the repo.
- If itโs just for personal workflows, add it to
.gitignore.
3๏ธโฃ .kamal/ โ โ
Add to .gitignore
- This contains deployment secrets and configuration files for Kamal (deployment tool).
- Itโs usually auto-generated and should not be committed.
4๏ธโฃ .vscode/ โ โ
Add to .gitignore
- User-specific VSCode settings, should not be committed.
- Different developers use different editors.
Keep These Files in Git (Don’t Add to .gitignore)
These files are important for project configuration.
1๏ธโฃ .gitattributes โ โ Keep in Git
- Defines how Git handles line endings and binary files.
- Helps avoid conflicts on Windows/Linux/Mac.
2๏ธโฃ .gitignore โ โ Keep in Git
- Defines ignored files, obviously should not be ignored itself.
3๏ธโฃ .rubocop.yml โ โ Keep in Git
- This is for Rubocop linting rules, which helps maintain coding style.
- All developers should follow the same rules.
4๏ธโฃ .ruby-version โ โ Keep in Git
- Defines the Ruby version for the project.
- Ensures all team members use the same Ruby version.
Final .gitignore Entries Based on Your Files
# Ignore log files, temp files, and dependencies
/log/
/tmp/
.bundle/
/node_modules/
# Manually added
# Ignore editor & environment-specific configs
.vscode/
# Ignore deployment configs
.kamal/
# Ignore personal GitHub configs (if applicable)
.github/
Final Summary
| Folder | Include in Git? | Why? |
|---|---|---|
log/ | โ Ignore | Dynamically generated logs |
public/ | โ
Keep (except public/assets/) | Static files like favicon, error pages |
script/ | โ Keep | Old Rails script files (if used) |
storage/ | โ Ignore | ActiveStorage uploads (except seed/) |
test/ | โ Keep | Contains important test cases |
tmp/ | โ Ignore | Temporary runtime files |
vendor/ | โ Ignore (except custom libraries) | Third-party libraries |
First time git setup
# You can view all of your settings and where they are coming from using
git config --list --show-origin
# Your Identity: The first thing you should do is to set your user name and email address.
git config --global user.name "Abhilash"
git config --global user.email abhilash@example.com
# configure the default text editor that will be used when Git needs you to type in a message
git config --global core.editor emacs
git config --global core.editor "code --wait" # vs code
git config --global -e # verify editor
# command to list all the settings Git can find at that point
git config --list
git config user.name
Add your ssh key to your github. Check the post: https://railsdrop.com/2025/03/30/setting-up-ssh-in-your-system/
Initial commit: Execute the Git commands
Run the following commands in your rails app folder:
git add .
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:abhilashak/design_studio.git
git remote -v # check the remote endpoints
git push -u origin main
git log # check commit details
What It Does:
git branch -M main
- Renames the current branch to
main. - The
-Mflag forcefully renames the branch (overwrites if needed).
Common Use Case:
- If your branch is named
masterand you want to rename it tomain(which is now the default in many repositories). - If you created a branch with a different name and want to standardise it as
main.
Example Usage:
git branch -M main
git push -u origin main
This renames the current branch to main and then pushes it to the remote repository.
Use github ssh option: it checks the ssh key that you setup in your github account for that machine.
http option asks your github credentials to login.
The -u option in the command:
git push -u origin main
What Does -u Do?
The -u flag stands for --set-upstream. It sets the upstream branch for main, which means:
- It links your local branch (
main) to the remote branch (mainonorigin). - After running this command once, you can simply use:
git push
instead of git push origin main, because Git now knows where to push.
Example Use Case:
If you just created a new branch (main in this case) and are pushing it for the first time:
git push -u origin main
This ensures that main always pushes to origin/main without needing to specify it every time.
After Running This Command:
โ Next time, you can simply use:
git push
git pull
without needing to specify origin main again.
For better git work flow
Check the post: https://railsdrop.com/2025/03/29/git-workflow-best-practices-for-your-development-process/
Want to See Your Upstream Branch?
Run:
git branch -vv
This shows which remote branch your local branches are tracking.
to be continued.. ๐