Mark
Mark

Reputation: 6464

how to add a symlink in the repository and some other questions

I just started studying the git. I have a project created, and I'm able to clone it, now I added a symlink inside the project and want to add this symlink in the repository:

% git add target/include/header.h
% git commit target/include/header.h

Is this correct sequence of commands, assuming that I want to commit only this single change?

Also: 1) Where does git keep authorization information, i.e. account and password which I used to clone repository? (so that I don't enter this every time) 2) Is there $HOME/.gitrc when I could keep frequently used definitions?

Thanks.

Upvotes: 0

Views: 118

Answers (2)

matrixanomaly
matrixanomaly

Reputation: 6947

  1. Is this correct sequence of commands, assuming that I want to commit only this single change?

Yes. Only if you're adding a new file. i.e You now have a new header file called square.h, you do git add, then git commit, as you would do. Git will commit all changes on the files it is tracking.

Tip: You can check what files have been touched/ untracked etc with git status

Tip 2: Personally I use git commit -am 'Message for the commit' as that commits all changes on the files it is tracking. What this means is that if you decide to change header.h, and then also at the same time touch header.cpp (which u previously already tracked), it will be aware of that change, and be committed as well.

Here's the documentation for git-commit

  1. In a config file, most user info is stored there. See this SO question. As far as I know, passwords aren't stored. You can cache the password, so you won't have to re-enter it X number of hours using the Git credential helper. See how to cache GitHub passwords, if you're using GitHub, and the official docs for git-credential store., the helper is in that section, too.

  2. Git reads configuration files, there's a global one, and a local one for every git.

Git Repo : /.git/config Home directory: ~/.gitconfig System-wide directory: $(pathprefix)/etc/gitconfig

If however you're referring to custom commands like how we can create our own in tcsh using .bashrc, that is mostly shell scripting that's independent from Git, have a look at this tutorial which basically asks you to create a custom script in your /bin/ directory.

Upvotes: 0

mipadi
mipadi

Reputation: 410552

  1. You can add symlinks just like any other file. (Create the symlink and then git add it.)
  2. It depends. Git uses different mechanisms for cloning. For example, if you use SSH, it will use your SSH keys (or require a username/password if you don't have SSH key auth set up). You can use Git's credentials mechanism to store usernames/passwords, too.
  3. Git will read a global configuration from ~/.gitconfig.

Upvotes: 1

Related Questions