Git autocompletion / Terminal

Hello!

has anyone typed the following in their terminal and if so, what would be the reason, and why would you do it manually? :

if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi

I’m trying to understand if configuring your terminal is necessary, or if just downloading the github desktop app, and just copy/paste or drag files directly is a sufficient way to use Github?

Also, auto-completion speeds up typing commands, so, what does completing a command based on what a user has typed…actually mean?

I’m still trying to figure git commands and github…

Thx for your time if you read this post,
Philip.

I’ve never felt that git autocomplete (or lack of it) would be a limiting factor.
As VSCode git integration is getting better and better, I’m more using it instead of the command line (never used Github desktop).

Lately I’m using git on command line only to create/switch branches, push/pull changes, and print the commit log. And I found that default terminal settings (autocomplete/suggestions by pressing Tab) are good enough.

And if you need to use some more complex git commands you’ll probably will be copy/pasting from StackOverflow anyway :wink:

1 Like

Thanks!

I’ll stick to default likewise…i’m not exactly a Linux pro.

Just means that if I press tab it’ll complete the command or show me a list of possible commands. Like git c<tab> will show me a list of git commands starting with c + their descriptions, and git com<tab> will automplete to git commit because that’s the only word that it could be.

No, because every time I’ve installed git anywhere it’s also installed the completions (eg when I’ve installed git it’s also always automatically added those lines somewhere, normally to my bashrc)

You can do the latter, it’s just inefficient. Some things are much quicker and easier to do in a terminal, by typing commands. Dealing with text files is one of those things. So for example, if I want to stage all files in a folder, add a commit message, push them to a remote, that might involve a few short typed commands. I never need to take my hands off the keyboard or even really look at what I’m doing in any detail. With a GUI it’s a lot of clicking and dragging and making sure I’m in the right place on the screen and filling in forms etc etc.

GUIs are fine. They’re just not optimised for doing that task. I still use a GUI for a few things; looking at a visual diagram of the branches of a complicated repo is one thing (I use Gitup, but there are a load of apps that do this: Gitkraken for example). For diffing I sometimes want a GUI, if there are merge conflicts I don’t want to be quick I want to be careful. Etc.

Stuff like Gitlens in VSCode or Magit or whatever are basically just thin wrappers over the CLI anyway.

1 Like

Thanks Dan,

What happened is, being unfamiliar with the Github desktop app, i somehow uploaded all my folders on the the app. (although they were not deployed in “repository” form, and the desktop app somehow new every single folder i had on my computer).

I panicked thinking all my personal files would be on some external app, then went into the terminal and typed a command that deleted everything on my computer. I mean everything. There are even 3 question marks on my dock meaning i probably deleted files of different apps i had installed previously.

I think i will stick with the terminal.

I still don’t understand why the word “repository” was invented, and i still don’t understand its definition.

In terms of creating my first repository, i’m not sure if i have to create a github.io website by default, or if for every single line of code or project i want to upload i need a new github.io “link”.

For instance,

here is a tribute page i made in its Chrome Browser version html link:

file:///Users/phil/Downloads/pen-export-xxPBXzX/dist/index.html

This is the codepen link:

I’ve also created a repository called: TributePage.github.io

Now depending on how i import my project, if for instance someone uses firefox as a browser, that means my Chrome .html link won’t work.

Therefore, i have to use the terminal, now, does that mean i should always have a file on my computer with that project?

Or since i use the terminal, the workflow of the importation makes it so, that the project is “duplicated” and therefore, stays forever on git, regardless if i have my tribute page on my drive or not?

You’re confusing two different things: version control (git) and deployment (in your case GitHub Pages).

The usual workflow is like this (assuming you don’t have to build your code):

You have source files on your computer that are tracked by git. When you change something you push your changes to GitHub and if you have GitHub Pages enabled it’ll do the deployment and publish your page under
https://your-github-name.github.io/your-repo-name/.

For tribute page that’s all you have to do.

1 Like

I think this depends a lot on your use cases:

  • I do a lot of stuff on servers, so I can not / must not install a lot of software, configs, gui tools: this is why I know all the important cli commands like: add (--patch), commit, remote, push, pull etc.
  • I work with other people, so they do not use all my tools like visual studio code: this is why I know how to do stuff in visual studio code, but also in the cli
  • sometimes I’m lazy, that’s why I have some alias for the cli: gap = git add --patch, gcm = git commit -m, gp = git push
  • because I have some longer commands, I use autocompletion for my shell (zsh)

I do not recommend learning git only with a graphical user interface. This works fine, until something does not work anymore. Then you have to invest a lot of time, because you probably don’t know the fundamentals.

I actually only use one “graphical” tool for git from time to time: the diff view in visual studio code.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.