git-commands

How can I force “git commit -s” using “git commit” command?

这一生的挚爱 提交于 2019-12-01 13:21:31
问题 I'm looking for a way to write the Signed-off-by: tag automatically when I commit. I tried configuring it through the .git/config file (Reference). I put these lines of code: [alias] commit = commit -s This did not work. As commented below, you can not edit git's own alias (like commit).(Reference) I also tried using the command (Reference): git config --global format.signoff true Also had no effect. This explains why. I'm looking for any solution that automatically places the tag and allows

How to know local repo is different from remote repo, without fetch?

霸气de小男生 提交于 2019-12-01 06:06:05
I got tens of repos, my script should update them if any difference happened, new commits, new tag, new branch. Fetch is kind of slow for tens of repos in my case, I'd like to know if there is any quick command could meet my requirement. mockinterface You can use the git ls-remote plumbing command to obtain the state of the remotes without fetch. Here, let’s use git itself as a lightweight database, to keep track of the state of the remote. Put the following in a script; you can enable it later as a git alias shell function for convenience. Run inside your repo. REMOTE_SUM=$(git ls-remote -

How to know local repo is different from remote repo, without fetch?

六眼飞鱼酱① 提交于 2019-12-01 03:34:17
问题 I got tens of repos, my script should update them if any difference happened, new commits, new tag, new branch. Fetch is kind of slow for tens of repos in my case, I'd like to know if there is any quick command could meet my requirement. 回答1: You can use the git ls-remote plumbing command to obtain the state of the remotes without fetch. Here, let’s use git itself as a lightweight database, to keep track of the state of the remote. Put the following in a script; you can enable it later as a

git add . vs git commit -a

喜你入骨 提交于 2019-11-28 15:24:30
What's the difference between: git add . git commit -a Should I be doing both, or is that redundant? git commit -a means almost[*] the same thing as git add -u && git commit . It's not the same as git add . as this would add untracked files that aren't being ignored, git add -u only stages changes (including deletions) to already tracked files. [*] There's a subtle difference if you're not at the root directory of your repository. git add -u stages updates to files in the current directory and below, it's equivalent to git add -u . whereas git commit -a stages and commits changes to all

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch

强颜欢笑 提交于 2019-11-28 02:30:33
I am using Git. I did a pull from a remote repo and got an error message: "please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch." I try to type a message and press Enter but nothing happens. How do I tell Git/terminal I am done typing in my message? I am using terminal on OS X. It's not a Git error message, it's the editor as git uses your default editor. To solve this: press "i" write your merge message press "esc" write ":wq" then press enter xiaohu Wang Actually it's not an error! It means you should enter some

Is there a better way to find out if a local git branch exists?

廉价感情. 提交于 2019-11-26 23:47:56
I am using the following command to find out if a local git branch with branch-name exists in my repository. Is this correct? Is there a better way? Please note that I am doing this inside a script. For this reason I'd like to stay away from porcelain commands if possible. git show-ref --verify --quiet refs/heads/<branch-name> # $? == 0 means local branch with <branch-name> exists. Update Turns out there is another way . Thanks @jhuynh . git rev-parse --verify <branch-name> # $? == 0 means local branch with name <branch-name> exists. Mark Longair As far as I know, that's the best way to do it

Is there a better way to find out if a local git branch exists?

北战南征 提交于 2019-11-26 08:47:37
问题 I am using the following command to find out if a local git branch with branch-name exists in my repository. Is this correct? Is there a better way? Please note that I am doing this inside a script. For this reason I\'d like to use plumbing commands if possible. git show-ref --verify --quiet refs/heads/<branch-name> # $? == 0 means local branch with <branch-name> exists. 回答1: As far as I know, that's the best way to do it in a script. I'm not sure there's much more to add to that, but there