Mastering git, Part 1, setting up git environment, GUI, mergetool, difftool

Installing prerequisite

Configuring Git Environment

First config your environment and set a proper merge/ diff tool.  The settings in Linux are under/home/<username>/.gitconfig.    If you don’t know where this file is located in your OS You can easily edit this file by:

All Git setting can be set or viewed via terminal, i.e:

To view all settings

Current settings of mergetool:

Set the merge tool

All available options for setting a merge tools can be listed by:

here we config it for meld, kdiff3 and vim.

Kdiff3

Add the following to your .gitconfig file

For Windows users:

 

Meld

For Windows users:

Vim

Username, Email and editor

Adding Alias

[alias]

or add it via the terminal:

SSH key

and upload your public key, located at
/home/<username>/.ssh/id_rsa.pub
into your GitHub account

If you have multiple accounts, you can create the following config file and save it under :

/home/<username>/.ssh/config

If you copy your key from a machine to your  .ssh directory, the permissions are too open and you  will get

So you need to:

Also, /home/<username>/.ssh/ the directory itself must be writable only by you:

Add the keys to ssh-agent:

and list them:

confirm the connection:

passphrases for SSH keys

if someone gains access to your machine, the attacker can gain access to every system that uses that key. You can add a passphrase to your SSH key to encrypt it. To avoid entering the passphrase every time you connect, you can securely save your passphrase in the SSH agent.

Change the passphrase for an existing private key without regenerating the keypair:

Change the passphrase comment:

 

Push into GitHub without a password using ssh-key

You have to change your remote type from http to git:

For example, if your repository is:

Then you have to run the following:

How to show the current branch in the Bash prompt

Edit ~/.bashrc and find the following lines and uncomment them

and replace them with

1, 2

Disabling Unix file permissions problem:
If you get the following message during a merge:

You have to disable the file mode. This usually happens when the repo is cloned between Windows and Linux/Unix machines.

Colors in Gitk

Yellow: Commit with the yellow circle is the HEAD. Gitk jumps to this commit once it got opened.
Red: Commit with a red circle is your uncommitted changes.
Blue: All other commits are shown in the blue circle.
Green: Local branches names are shown in green,
Orange, and green:  remote branch names are shown in a combination of orange and green, with the orange section being the remote name and the green section being the branch name.

Ignore list

you can use .ignore and .git/info/exclude

gitattributes

you can use .gitattributes and .git/info/attributes

Refs: [1]

 

How to get the root of Git repository

How to commit part of a file

You can use:

or

and then

not

If you are using git-gui, you can mark chunks that you want to have included in the commit by right-clicking them and selecting: “Stage Lines For Commit”

 

Refs: [1]

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x