DEV Community

Discussion on: Why you need Terminal

Collapse
 
nrobinson2000 profile image
Nathan Robinson

I have this function in my .bashrc for quickly committing and pushing my changes in a repo.


function update()
{
  cd "$(pwd)"
  git add -A
  #git commit -S -m "$1 at $(date +"%H:%M") of $(date +"%Y-%m-%d")" # Replace the line below with this one for GPG signed commits
  git commit -m "$1 at $(date +"%H:%M") of $(date +"%Y-%m-%d")"
  git push -u origin $(git rev-parse --abbrev-ref HEAD)
}

I can just do update “message” and all changes will be committed using my GPG key, the commit message gets appended with a timestamp, and gets pushed immediately.

I also have this function will lets me do a git pull for all repositories in a directory.

function pull-all()
{
  CWD="$PWD"

  for OUTPUT in $(ls -1 "$CWD")
  do
    if [ -d "$CWD/$OUTPUT/.git" ]; # Only do git pull if it is a repository
    then
      cd "$CWD/$OUTPUT"
      echo "Pulling $OUTPUT..."
      git pull
      echo
    fi
  done
  cd "$CWD"
}

It’s very convinient because I can cd to my central git directory and run pull-all to git pull all the repos.

Collapse
 
vinayhegde1990 profile image
Vinay Hegde • Edited

This is a very concise article explaining the importance of the Terminal since most people are usually in favor of the GUI [due to the assumption the CLI is only for hackers ;) ]

One more way to do a Git pull on your multiple Git repos without ever changing to your central git directory is by installing and using gitup. I personally have used it for 8 repos which worked flawlessly.

It's just a one time setup and on every pull, it'll show you all the objects that were updated for each repository right in your terminal (depending on any color scheme you use, this is a very cool thing to have :D ]

Hope this helps, cheers!

Collapse
 
aurelkurtula profile image
aurel kurtula

That's a lot more sophisticated than what I have. I didn't even think of adding the time stamp. I'll definitely borrow that :)

I might borrow the pull-all though to be honest I do not understand it at all. Though I use git daily for my private repos, I haven't yet contributed to any open source (which if I'm not mistaken is what pull is mostly used for).

Thread Thread
 
nrobinson2000 profile image
Nathan Robinson

Pull is also used if you are working on a repo on multiple devices (even if they are your own and it’s a private repo).

Thread Thread
 
aurelkurtula profile image
aurel kurtula

Oh yes, but never had to :)