Lenora  Hauck

Lenora Hauck


Faster Git Workflow With Git Aliases

Git is an intricate part of our development workflow. There are handful of commands that you keep repeating day in and day out. I always relied on the command suggestions, or packages on top of my shell that gave access to handy git aliases.

But usually you had to stick with the aliases decided by the package creators . Although most of the aliases included are unofficially globally accepted like ga for git add and so on.

But guess what? You don’t have to rely on any third party packages ; you can create your own with the aliases you prefer!

There are two ways of creating Git aliases: ✌

with the git config utility 💻

This is the preferred way of adding aliases as git gives you an option to do so. Suppose you feel tired of repeating the commit command every now and then. It would be nice if we could create an alias to write our commits faster.

The above command follows the following syntax:

Now we can use the c alias to represent commit -m .

git c "Update readme with social links"

editing the .gitconfig file 📝

It would be tedious to add multiple aliases with the git config command, so there’s an easier alternate approach.

All the alias you create is saved to the .gitconfig file sitting in your home directory. We can open the file and add our aliases following the TOML formatting. Make sure you do not modify anything in the file apart from adding the [alias] table and its contents.

Open the file using your favorite editor.

vim ~/.gitconfig ## or code ~/.gitconfig

Start adding your alias ✍️

You can use the above aliases as follows:

git st ## git status 
git c "hello world" ## git commit -m "hello world" 
git a hallucination.py ## git add hallucination.py 
git cb multi-stage-build ## git checkout -b multi-stage-build

#command-line #git #github #productivity #programming

What is GEEK

Buddha Community

Faster Git Workflow With Git Aliases
Madyson  Reilly

Madyson Reilly


Best Practices for Using Git

Git has become ubiquitous as the preferred version control system (VCS) used by developers. Using Git adds immense value especially for engineering teams where several developers work together since it becomes critical to have a system of integrating everyone’s code reliably.

But with every powerful tool, especially one that involves collaboration with others, it is better to establish conventions to follow lest we shoot ourselves in the foot.

At DeepSource, we’ve put together some guiding principles for our own team that make working with a VCS like Git easier. Here are 5 simple rules you can follow:

1. Make Clean, Single-Purpose Commits

Oftentimes programmers working on something get sidetracked into doing too many things when working on one particular thing — like when you are trying to fix one particular bug and you spot another one, and you can’t resist the urge to fix that as well. And another one. Soon, it snowballs and you end up with so many changes all going together in one commit.

This is problematic, and it is better to keep commits as small and focused as possible for many reasons, including:

  • It makes it easier for other people in the team to look at your change, making code reviews more efficient.
  • If the commit has to be rolled back completely, it’s far easier to do so.
  • It’s straightforward to track these changes with your ticketing system.

Additionally, it helps you mentally parse changes you’ve made using git log.

#open source #git #git basics #git tools #git best practices #git tutorials #git commit

Git Merge: A Git Workflow explained 

What is Git Merge?

Merge is a command used in Git to move the changes in branch to another. Usually, the new features are developed in the dev branch and merged into the master branch after finishing the development. All the changes in the dev branch is added to the master branch on the merge. but the dev branch will be unaffected.

— merge pic —

How to do a Git Merge

Let’s do a Git Merge step by step to understand how it works. Except the merging part, many steps from cloning the repo to publishing the changes will be the same as in Git Rebase Tutorial because we are trying to do the same thing in a different way.

Step 1: Fork and clone the desired repo

Let’s reuse our rebase-demo repository for this. Go to https://github.com/kdanW/rebase-workflow-demo and click the button ‘Fork’ in the top right-hand corner. Now go to your forked repo, click ‘Clone or Download’ button and copy the link shown.

Image for post

Now go to a directory of your preference and type the following command on the terminal to download the repo into your local PC.

git clone https://github.com/<YOUR_USERNAME>/rebase-workflow-demo

#git-merge #git-workflow #github #merge #git

7 Best Practices in GIT for Your Code Quality

There is no doubt that Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Still, developers struggle for code quality. Why? They fail to follow git best practices. In this post, I will explain seven core best practices of Git and a Bonus Section.

1. Atomic Commit

Committing something to Git means that you have changed your code and want to save these changes as a new trusted version.

Version control systems will not limit you in how you commit your code.

  • You can commit 1000 changes in one single commit.
  • Commit all the dll and other dependencies
  • Or you can check in broken code to your repository.

But is it good? Not quite.

Because you are compromising code quality, and it will take more time to review codeSo overall, team productivity will be reduced. The best practice is to make an atomic commit.

When you do an atomic commit, you’re committing only one change. It might be across multiple files, but it’s one single change.

2. Clarity About What You Can (& Can’t) Commit

Many developers make some changes, then commit, then push. And I have seen many repositories with unwanted files like dll, pdf, etc.

You can ask two questions to yourself, before check-in your code into the repository

  1. Are you suppose to check-in all these files?
  2. Are they part of your source code?

You can simply use the .gitignore file to avoid unwanted files in the repository. If you are working on more then one repo, it’s easy to use a global .gitignore file (without adding or pushing). And .gitignore file adds clarity and helps you to keep your code clean. What you can commit, and it will automatically ignore the unwanted files like autogenerated files like .dll and .class, etc.

#git basics #git command #git ignore #git best practices #git tutorial for beginners #git tutorials

Use “git add” smarter with “--patch”

When I first learned how to use git, I was presented with a list of steps to follow. First, use git add -A to add everything that is changed into the commit. Second, create a commit with a message using git commit -m “This is my message”. Lastly, git push to push my commit to the code repository. Pretty simple, right?
Now, if you have done quite a bit of coding in an established codebase, whether open source or in a company, you know that git add -A is not a command that you use very often, if not at all. For the most part, people tend to add files to a commit one at a time, using either a GUI or via the command line with git add <file_name>. I am guilty of using the latter approach. I was introduced to git via the command line, like many developers, and never really wanted to learn a GUI tool that probably calls the command line under the hood anyway.

#git-interactive-mode #git #how-to-use-github #developer-workflow #git-workflow

Loma  Baumbach

Loma Baumbach


Mirroring Git Changes From One Server to Another Server


Hello all, nowadays most of the development teams using GIT version control, some of you may have a requirement of mirroring your team’s git changes from one server to another Git server. This article will help you to achieve the Git mirroring between one server to another server.

Business Case

I got one assignment wherein there will be 2 Git Servers, development will happen in one Git server and the changes should be synchronized to another Git server at regular intervals. But in my case, the complexity is both the servers are in different restricted network. So I have done the small experiment and it worked. And I am sharing the steps to you all in this article.

The Experiment Performed Using Below 2 GIT Servers

Main GIT Server: Let’s take our main git server is located in our office and can be accessed only in-office network.

**Mirror GIT Server: **The mirror server is located at the vendor/client-side, which can be accessible in a normal internet connection but not with our office network. Since the office proxy will block the outside URL’s.

#devops #git #git and github #git best practices #git cloning #git server