Git equivalent status svn -u

Which is equivalent to git svn status -u or the more detailed svn status --show-updates . The svn status --show-updates command shows the updates that the svn update will print from the server.

Thank!

+45
git svn
Jul 16 '09 at 17:13
source share
7 answers

I can’t think of a way to do this without selecting updates (maybe someone else). Assuming you are in the "master" branch by default, and the upstream from which these hypothetical updates will appear is the remote "origin" by default, try ...

 git fetch git log --name-only ..origin/master 

Pay attention to double points .. not one point or not elipsis 1 .

This will give you a list of log entries for changes that are only upstream, with the affected file names, you can change the parameters in git log to get more or less information.

NB in ​​git, fetching these updates is not the same as applying them to a local branch. You undoubtedly already know how to do this with git pull.




1 As for where the double points come from, name1..name2 indicates the range. If name1 omitted, HEAD used in its place. This syntax applies to all commits reachable with name2 back, but not including, HEAD . [ Git bottom up

+34
Jul 16 '09 at 17:26
source share

Both Martinho Fernandes and tialaramex correctly answer what you need to do. Let me describe why this is so.




Subversion

Subversion is a centralized version control system. This means that it works in client-server mode: the server stores all version data (repositories), the client has only a working directory (files) plus some administrative and auxiliary data. This means that for most commands, the client must contact the server. This also means that there are many commands requesting the status of the repository on the server or server configuration, for example, " svn status --show-updates ".

(Sidenote: one of the supporting information that Subversion stores on the client is the “original” version of the files, which means that checking for changes does not require a server connection (which is slow) ... but it also means that SVN checking can be more git repository).

"svn update" (required before commit, if the repository has any changes in this branch) downloads the latest version from the remote and merges (tries to merge) the changes you made with the changes from the remote. IMHO this workflow from upgrade to commit is not very well done.




Git

Git is a distributed version control system. This means that it works on a peer-to-peer basis: each “client” has all version data (full repository). A central repository is central only because of a social convention, and not technical limitations. This means that when accessing another remote repository, the number of commands "remotely executed" is very small. You can request links (aka. Branch and tags headers) using "git ls-remote" (and "git show update"), you can pull (receive) or click (publish) data using "git fetch" (or " git remote update ") /" git push ", and if the server is configured to allow it, you can get a snapshot of the status of the remote repository using" git archive --remote ".

So, to check the commits that are in the remote repository, but not present in your repository, you need to download the data to your computer. But "git pull" is actually nothing more than a "git fetch" that loads data and a "git merge" that combines it (with a little sugar to prepare commit messages and choose which branch to merge into). Then you can use "git fetch" (or "git remote update"), examine the newly received commits with "git log" and "gitk" (not limited to a fixed output), and then if all the right merges with "git merge" are all .

This does not apply to Git, but to all distributed version control systems, although the way of displaying SCM, but not related to it, may differ (Git uses remote tracking branches in 'remote / <remotename> / *' namespace, Mercurial from the fact that I understand, uses unnamed chapters).


NTN

+30
Jul 16 '09 at 22:42
source share

If you have chosen:

 git fetch <remote> 

instead of stretching:

 git pull <remote> 

on the remote control, you can check what has changed using git log . To apply the changes:

 git merge <remote>/<remote-branch> 
+13
Jul 16 '09 at 17:23
source share

You can use git ls-remote to display SHA links in a remote repository; so you can see if there are any changes comparing the output:

 $ git show-ref origin/master # <-- Where this repo thinks "origin/master" is 5bad423ae8d9055d989a66598d3c4473dbe97f8f refs/remotes/origin/master $ git ls-remote origin master # <-- Where "origin" thinks "master" is 060bbe2125ec5e236a6c6eaed2e715b0328a9106 refs/heads/master 

If they are different, then there are changes in the sample:

 $ git remote update Fetching origin ... From github.com:xxxx/yyyy 5bad423..060bbe2 master -> origin/master 
+4
Feb 04 '13 at 0:35
source share

For me, just to display the files that will be modified is:

 git fetch (1) git diff --name-only ..origin/master (2) 
  • Selects changes to the Git database (in the .git directory only) and does not change the files.
  • Shows the names of files that will be changed after merging

To update files (not just Git "database") do Git merge

+3
Nov 24 '11 at 21:31
source share

Gits gives us more tools to check for "updates." First you need to “download” the updated state of the repository:

 git fetch 

Now you can get the list of modified files:

 git log --name-status ..origin/master 

Additionally, you can see the full list of changes using diff:

 git diff ..origin/master 

The meaning of the starting letters: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), Changed (T), Unmerged (U), Unknown (X) or had Broken pairing (B)

+2
Nov 19
source share

git fetch && git log --name-status ..origin/master really shows the logs to be merged. However, it also carries change. It is technically impossible to do the same as svn status -u , but git fetch is so fast that it usually doesn't matter

If you absolutely need a log before extracting, the only way is to connect (SSH or equivalent) to the remote computer and issue git log there.

+2
Nov 19 '12 at 17:16
source share



All Articles