Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
/ sit Public archive

sit: a simple manager for git repos

Notifications You must be signed in to change notification settings

Ma-Nu-El/sit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 

Repository files navigation

Table of Contents

  1. sit: a simple repo manager for git
    1. preamble
    2. Kind of licensing?
  2. problem [why bother in the first place]
  3. current solution [way too inefficient]
  4. wanted solution [maybe too good?]
  5. how to get there [middle term once again?]
    1. add locations
      1. verb
      2. if
      3. fi
    2. display the locations
      1. if
      2. fi
    3. git status part
    4. git commit part
    5. git push part
    6. git pull part

sit: a simple repo manager for git

preamble

The source code for the Markdown and the actual executable file is the .org file itself. I just tangle the sit file and export to Markdown using Orgmode's C-c C-e m m.

Kind of licensing?

By the way, I haven't read about licenses, but I know that I don't want to get charged for using this stuff now or in the future, so I guess I'd be opting for something like the GPL/MIT/BSD branch.

Please feel free to do whatever you want with this code, I just want to type less (and remember less) in order maintain my scattered git repositories.

problem [why bother in the first place]

I type too much just to commit and push in different git repositories in my machine.

Plus, it's a nice motive to learn bash.

current solution [way too inefficient]

I have to cd into every git repo - which by the way have to remember its location every time for every repo -.

From here I usually do one of the two following actions:

  1. Copy the commit message and paste it on the next commit of all the other git repos.

  2. Push.

Maybe I haven't pushed up the different git repos and now after committing in each repo (related or not) I want to push them up. That involves cd <insertGitRepoLocation> and then git push and repeat again for every repo.

This workflow is a problem because:

  • I have to remember where are all these different repos

Note that the number of repos is highly variable, so getting used to remember some locations is not an option since you could easily forget that particular little test repo you needed to commit/push. I have forgotten those. It's annoying.

  • Since I have these repos scattered in multiple directories in multiple machines, it's very error prone
  • git submodules/subtree/subrepos are way too complex for what I need

wanted solution [maybe too good?]

If I'm in the $HOME folder, then just git status right from the $HOME directory only to be aware of the changes made to the different present git repos.

I'd be committing every change to its corresponding git repo with the same message. Very much as if I cd into every repo and git commit right from each one manually; as already explained it's an error prone and cumbersome way to do.

In the same way, I could push with one command or push from each one, I want to have that flexibility also.

how to get there [middle term once again?]

Usually, I have to remember where are these repos located.

That can be solved using a simple array variable to store the locations of the different git repos; the locations should always be the same across machines and the same relative to the $HOME directory.

Something like

declare -A repositories

DONE add locations

verb

I could use something like "sit add". For the first time, it has to be manually done. And as well, you should be able to add multiple directories at once.

if

if [ $1 == 'add' ]
then

REPO_NAME=$2
REPO_DIR=$3
echo $REPO_NAME>>repoNam.txt
echo $REPO_DIR>>repoDir.txt

fi

fi

display the locations

if

if [ $1 == 'ls' ]
then

echo "repo nicknames"
cat repoNam.txt
echo ""
echo "repo locations"
cat repoDir.txt
echo ""

fi

fi

git status part

Next thing is to collect the output of git status performed in every single repo and display that collected info in just one message. The info of that message should contain the repo location followed by the actual output of that git status command performed in that repo. And repeat for every repo location.

yourRepo1/
- changes not staged for commit
- blah blah balh

yourRepo1/
- changes not staged for commit
- blah blah balh

git commit part

Here's when you need more flexibility. There are usually two scenarios:

  • you want to commit everything at once, sharing the commit message.
  • you've made changes related to different things and you need different commit messages.

For the first option, the algorithm to commit should be the same as the git status algorithm, except that now you have to input a commit message shared for every repo.

For the second option, you just cd into every repo and commit using your appropriate message, just as we've always done.

git push part

Same idea for the commit part.

git pull part

Since I don't have the same repos across different machines, the pulling is not the same process as committing and pushing. So for the moment no implementation for pulling. But if I wanted, the algorithm should be very much like the commit and push part.

About

sit: a simple manager for git repos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published