Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git changelist's

I am fairly new to git and by now i know the basics. Even tho I use a plugin/program with a GUI to work with git in my daily work, I really like to know what is going on behind the scenes.

I am normally working in Intellij and there I am able to split my changes up in different 'changelists'.

As seen on the picture below I have a changelist with markdown files and a default changelist with script changes.

Here is a picture showing it:

enter image description here

I am wondering if the changelist is a concept in Git or just a concept made up in the Intellij plugin?

If it's a concept in Git, what is the commands needed in the command line?

like image 406
RooKie- Avatar asked Oct 12 '16 07:10

RooKie-


2 Answers

Changelists are predating the integration of Git in IntelliJ IDEA, so they are a concept from IntelliJ, allowing you to split your changes in different sets.

I explained how they were linked to a Git commit in "What is a changelist in IntelliJ IDEA?".

Since there is only one index (staging area) in Git, there is no direct command-line equivalent.
git stash is a poor substitute, as long as you are using --keep-index, in order to preserved the staged changed in your working tree.

like image 164
VonC Avatar answered Sep 21 '22 19:09

VonC


I don't know how IntelliJ handles git internally, and git does not have a concept of different changesets, but something similar.

Staging

A commit does not commit your current working-directory but your staging area. You need to stage everything you want to have in your next commit first. This can be used to split work in multiple commits, you can stage files or even parts of a file (hunks). But there is only one staging area, so you can not really split your work in different changesets. Instead, you stage what you want to have in your commit, then commit, then repeat.

Stashing

If you're working on something but need to stop your work on this feature and instead work on something different you can stash your changes. This stores your changes in a stashing-area and cleans your working-directory to the HEADs state. When you're done with your other change you can reapply the stored changes onto the working-dir and continue working on this feature.

Branches

Use Branches, Branches are good. Use lots of them, merge often. Create a branch for every feature you are working on and commit your changes. Switch to a different branch, work on something different. If a feature is finished, merge it to master (or your develop-branch or what not). Keep different things you're working on in different branches. This prevents you from breaking one part of your work when you half-finished another one which is still buggy.

like image 33
tkausl Avatar answered Sep 22 '22 19:09

tkausl