Once a directory is renamed, "git log" no longer shows its history, unless you force it to, by using "git log --follow".
Is there a way to force the "history" function on the GitHub web UI to use "--follow"?
Alternatively - is there any way to see pre-rename history on GitHub?
Update June 2022: GitHub now supports viewing commit history across file renames and moves!
.
2011: This was requested in 2009 (Request 129), and then in 2010 (Request 897), and then in 2021 (github/feedback discussion 6964):
I like this.
There could be other issues preventing us from plopping the --follow argument in.
I'll take a look and let you know.
... and then nothing for now.
Note: Git 2.6+ (Q3 2015) will propose that in command line: see "Why does git log not default to git log --follow?"
Note: Git 2.6.0 has been released and includes this feature. Following path changes in the log command can be enabled by setting the log.follow config option to true as in:
git config log.follow true
I wrote a chrome extension to enable this. Source on github.
I've sent a mail to support#github.com (salutations removed):
Will "git --follow" functionality ever be implemented on Github? If yes, where can I track its progress?
(By "git --follow", I mean a way to easily see the object revisions before a rename. Currently, when an item is renamed, Github doesn't offer an easy way to display the directory / file history.)
Response:
> Will "git --follow" functionality ever be implemented on Github? If yes,
where can I track its progress?
This is something a few other users have requested as well -- we might add it in the future. We currently don't have a public issue tracker, but I'll put another +1 next to it on the Feature Request List™ for the team to see.
So, "git --follow" is unfortunately not supported yet.
To get such functionality in the meantime, I guess you could write a user script that looks up the hash of the parent object, (recursively) look up its history and render the result.
Related
We recently moved to git from svn (both using Eclipse). I am in the (perhaps bad) habit of writing my Java code first, getting everything to work and then going back and adding comments. In SVN this was easy. I would just create a Fisheye review with my Jira task. The review would have a list of all the files I changed and methods I added or modified. I would note it and abandon the review. Then I would edit all the files listed and add the comments.
However, Fisheye does not (I believe) work with git. I could do a git status to see the files I changed but the local branch is already updated so it will not list any files. And all it does is tell me I am something like one commit ahead of the remote branch but does not list any files.
Is there some way to see a lit of the files I have changed with git so I can add comments? And when I say I wait for my comments I really mean mostly for added classes and methods. If I do something like add a line or two to a method I will generally add the comment too.
changing comments on git commits is not that easy. Each git commit has a sha-checksum which also includes the previous git commit. If you change a commit you change the current commits sha-checksum. therefore you create a new commit. All following commits of your branch must now be rebased on top of this new commit.
The command line provides the git rebase -i [commitid] where you can do lots of modifications including changing comments on commits. I never did this with a GUI but egit might support that too. Just refer documentation on egits rebase feature.
I found out how to do this.
The "Synchronize Workspace" in eclipse appears to show all the changed files not yet pushed remotely. I have not done any pushes, so this showed me what files changed.
I'm transitioning from using Subversion in Eclipse for code management to GitHub in RStudio. It's starting to make sense, but I can't seem to figure out how to pull effectively.
Specifically, if I use the Pull arrow in RStudio, every file change in the repository automatically updates my local files without warning. I can see how many files were updated, but not what changed!
Here are the questions I'm hoping to get help with:
1) Can I preview the repository file changes in RStudio before I pull them locally? With SVN in Eclipse, there was an indicator showing files with a difference, and the option to view side by side.
2) If multiple files have been changed on the repository, is it possible to pull just 1 locally?
3) How can I revert a local file to a previous version?
Right now I've been trying to do this all within RStudio for simplicity. I haven't used things like the GitHub desktop client.
I appreciate the help!
I would suggest you better get used to the git's own tools to stay informed about your repository.
For example you could do following.
Before you pull, check your current commit logs
git log
This should show you how your current commits stack up. Note the latest commit id (first 4-5 letters would usually do)
Now after pulling you can see the difference using following command
git diff --color your_previous_commit_id..HEAD
If you don't like the changes and want to go back,
you can just reset to your favorite commit with following command. BTW run "git stash save" to keep a copy of your uncommitted changes.
git reset --hard you_favorite_commit_id
Note: that this will delete all your uncommitted changes unless you stashed them and put your local branch behind the remote repo branch you are tracking again.
Wondering where to put these commands? Check https://git-scm.com/downloads.
What's good about using these git tools is that if you switch between IDEs you don't need to search for same functionalities you had in your earlier IDEs.
I have successfully been able to "diff" two files using the stash git API, however, each time you have to specify the full hashes of the commits, like so:
rest/api/latest/projects/{project}/diff/{path to file}?since={hash}&until={hash}
What I would like to do is something like this:
rest/api/latest/projects/{project}/diff/{path to file}?since=HEAD^^&until=HEAD
To resemble:
git diff HEAD^^ HEAD {my_file} (So diff between the HEAD and previous commits on that file.)
The only way I have been able to get a list of historical commits from the API is using the following from their docs:
https://stash.atlassian.com/rest/api/1.0/projects/JIRA/repos/jira/commits
which will: "the latest commits to the jira repository in the JIRA project" but not for a specific file.
From what I have been able to find it seems as though the API does not support this functionality.
I have been able to solve this, thanks to my Firfox console. The UI makes use of a history drop down showing the last 25 commits to the file with the following URL:
rest/api/latest/projects/{project}/commits?path={path_to_file}&until=refs%2Fheads%2Fmaster&start=0&limit=25
I'm new to using github with visual studio 2015 plugin and I'm stuck.
I created a new project on github and was able to link the depot to my visual studio project. I was able to sync some code up to the depot.
Then I added a readme file to my project on github from the website. Next day I made more code and decided to sync it up to the depot, but now it says that I have incoming commits (the readme file). I clicked on fetch on the incoming commit but nothing happens. I clicked on pull and it says my changes would be overwritten by merge.
I then went to outgoing commit (the ones i just made) and click on push. it says that "You cannot push branch master to remote origin because there are new commits in the remote repository’s branch. Pushing this branch would result in a non-fast-forward update on the branch in the remote repository"
i click on several things and i still can't resolve this issue. I want to update my current project with the readme and then update my depot. (i also am new to the terminology)
The trouble is that you've got changes on the server, that are committed, and changes to some of the same files on your local copy that conflict with it to the extent that Git can't figure out which ones should "win".
You'll have to look at each file that has conflicts, understand where the conflicts are, sort them out, tell git that you've sorted out the file, and then progress.
So Fetch will bring all of the changes down from github, locally, but not change your working copy.
Merge is intended to pull down the changes in your current branch and merge them in (and that's where it's having trouble).
Best recommendation for working with git (whether Visual Studio or not)): Fetch and merge often. Every day at least.
This page looks like a reasonable tutorial on how to do it. It looks similar to my VS2015 git plugins.
https://msdn.microsoft.com/en-us/library/dd286559.aspx
This page is quite a good tutorial on doing it from the command line:
https://easyengine.io/tutorials/git/git-resolve-merge-conflicts/
(But I've got to say: the Visual Studio tool makes it easier).
So the key points are:
look at each file and fix the conflicts.
tell git that you've fixed the file
Once you've done all the files, you need to "commit the merge"
Then you're in a place to commit your local changes and push them up to the server.
Second tip: Most people that I know who use git with visual studio also use the command line client extensively, and usually have an additional gui client (such as Atlassian's Sourcetree) as well. I use all three every day.
I managed to finally get EGit in Eclipse to work (still don't know how) and I've committed/pushed my current project up to GitHub. So far, so good. Looking at it on GitHub's site, I see it wants me to make a README.md file to provide a nice description. Fine, I think, I'll just use the tool it's providing me with to get it started, then have it sync back down to my local computer where I can further modify it and keep it synced.
So I created a quick README.md file on GitHub's site. But now, when I perform a "Pull" action in Eclipse, I am told that there's nothing new to pull, or something like that. Why is it not getting the new file that was created on GitHub's site, and how can I get it so that I can make changes to it whenever I want?
If you have git installed you can use a terminal and type in the root of your repository:
git pull origin master
or you could try checking out only that file:
git checkout README.md