Questions tagged [git]

59792 questions
1

votes
2

answer
820

Views

how to do an export for git stash

I want to export one stash (the changes) that I see in my stash list in a .zip/.gz file. I have found the following command: git stash show -p > patch which saves the changes in a file, but I also want to keep .png files, etc... I am looking for a way to compress all of the changes contained in the...
epi4
1

votes
4

answer
1.8k

Views

Create new branch from specific commit onwards

I want to create a new branch, starting from a certain commit. However, I want all the commits that were commited afterwards to be part of that branch too. Lets assume this is branch-D with all the commits. > branch-D commit-A ---- commit-B ---- commit-C ---- commit-D I want to remove everything fro...
Stophface
1

votes
1

answer
24

Views

Show branches not up to date with other branch

I'm creating a git alias to merge master to outstanding development branches after we've had a deploy. I can find out which branches are not merged into master with this command: git branch --no-merged master. However, from that list, I can checkout the unmerged branch, and its possible that the ne...
user151841
0

votes
0

answer
4

Views

How to get the directory git detail from repo in GitPython?

I would like to get the number of commit of a directory(called module) from a repo(project) in GitPython. > print('before',modulePath) > repo = Repo(modulePath) > print(len(list(repo.iter_commits()))) When I'm trying to print the directory amount of commits, It says the repo is...
Get Rept
1

votes
2

answer
378

Views

Show a contributor's number of commits and lines of code contributed

I would like to view a summary of my total number of commits and total number of lines of code which I have committed to a particular repository on GitHub. Is there any way to do this using either: GitHub, Git Shell on Windows, or another tool which easily works on Windows or in a web browser? Here...
Patrick Parker
1

votes
1

answer
129

Views

Cherry Pick a Squashed Commit

I have two main branches, staging and master. I have a few commits and I have pushed those changes to a branch say xyz whose base branch is staging and have created a pull request for staging branch. All these commits has been squashed into a single commit. Is it possible to cherry pick this squash...
Nidhin S G
1

votes
2

answer
203

Views

Is there a way to specify a default option for merging a pull request in GitHub?

I'm working on a project where 'squash and merge' is the preferred approach for merging pull requests. Is there a way to make this the default option in GitHub, either for my own user, or for the project? As it stands, it's entirely too easy to select the default option (Create a merge commit). Th...
M. Justin
1

votes
1

answer
331

Views

How to reset remote branch to certain commit?

Okay so here it is, a mess was made and we need to reset a branch to a specific point in history. At this point I have gone into SourceTree and locally reset the branch to the appropriate commit. How do I get the pushed branch to match? Currently it says I'm multiple commits behind and I'm not sure...
Casey West
1

votes
1

answer
1.1k

Views

Git warning: unable to access '/home/user/.gitconfig': Is a directory

I am getting this error for every git command I try to run and haven't found anywhere something similar. I have found stuff like 'permission denied' and other problems to access the git configurations but nothing related to this 'Is a directory' warning. I don't even know if it is related to the fat...
1

votes
2

answer
717

Views

git -diff to also show commit message

I currently have something like this in my code: git_cmd = 'git diff --name-only %s...HEAD %s' % (options.commit_id, options.path) proc = subprocess.Popen(git_cmd,stdin=PIPE, stdout=PIPE, stderr=PIPE) changed_files = proc.communicate() It pulls what files have been changed or added between a certain...
Marek Wojnicz
1

votes
1

answer
342

Views

Azure DevOps default permissions

In Azure DevOps, branch security for git repos defaults the 'Force push' property to 'Not set' for all Azure DevOps Groups. This effectively denies this permission. We're following gitflow where I work and would generally deny this permission explicitly for persistent branches, Master and Develop; h...
Ryan.Bartsch
1

votes
2

answer
225

Views

Git reflog expiration time

I have known that reflog entries gets deleted which are older than 90 days. I have not made any change in git config too regarding this. Today when I did git reflog master --date=local, I can see entries of 10 months before in it. How is that possible ?I should only be seeing entries dating back to...
Breaking Benjamin
1

votes
3

answer
133

Views

How are different branches stored locally from git on my disk?

I have only one version repository sitting on my local HDD but multiple branches on Github. Shouldn't there be copies of code per branch? what version of code do I have sitting on my local disk?
Sarun Luitel
1

votes
5

answer
82

Views

How to pull a pull request from upstream in github

I have forked a repo in github. There are some new pull requests in the Upstream. I want to pull a pull request from upstream locally. How can I do that? I have no idea and found nothing related to this.
Noor A Shuvo
1

votes
2

answer
47

Views

How can I get the name of the last person who committed on a remote?

I know that the option -force-with-lease allows me to push force only if I was last committer but I would like to allow overriding it: git push playground $current_branch:master --force-with-lease if ! [[ '$?' == '0' ]]; then last_committer='$(git some command)' ask_continue 'the last committer was...
Ulysse BN
1

votes
0

answer
17

Views

How do I ask git for all the tags on a specific commit?

How do I ask git for all the tags on a specific commit? I feel like this should be easy but I am not finding it in the man pages. Do I need to do multiple commands for this?
algal
1

votes
0

answer
9

Views

How to quit (not abort) a Git merge in progress keeping the changes uncommitted?

When a Git merge stops due to conflicts or because the user asked for it by using the --no-commit option, the merge is considered to be still in progress, what is indicated by the existence of the file $GIT_DIR/MERGE_HEAD. This state typically ends when the merge result is committed or the merge is...
Jürgen
1

votes
3

answer
76

Views

rename a branch in gerrit

I have a change in Gerrit review in my current branch name called 'foo'. I want to change the branch name to 'bar', so I've used following command. $ git branch -m bar and then I did the git amend as I need the change of branch name appears to Gerrit review as well. $ git commit --amend However whil...
smc
1

votes
2

answer
207

Views

Git initial push fails pre-receive hook declined

I pulled a repository and cleaned irrelevant parts. Locally everything is perfect. I want to keep history from previous repo. Then I created another repository, a clean one. But push is failing due to pre-receive hook declined I am quite sure I don't have that kind of stuff on my repository :) I tri...
tkcn
1

votes
2

answer
50

Views

How to parse git diff of specific file using Ruby?

I have an Android XML (string) file that is edited in a Ruby script. I would like to list and output the changes that were made then. I have tried it with Nokogiri and nokogiri/diff. But it does not have the desired result. I also have the feeling that it has problems when a new line is added in the...
FrostX
1

votes
2

answer
22

Views

Git branching strategy issue

Currently we are using a GitFlow approach to our branching strategy. However we came across the following scenario. We created a release branch. There were a couple of bugs that needed a fix on the release branch. In the meantime since the development continued on the develop branch there were addit...
igalbenardete
1

votes
2

answer
21

Views

How can I create a pull request from a fork without having created a branch on the fork?

I created a fork on Github, worked on the fork and now I want to create pull request for the original project to take my changes. All the documentation I can find here, GitHub and Google refers to a branch being selected for the pull request, but I did not create one. How can I proceed?
rob
1

votes
1

answer
22

Views

Plumbing equivalent of 'git diff REVISION'

git diff respects color.ui=always, among other things. Is there an equivalent plumbing command that will always give me a valid unified diff that I can apply using patch?
Edward Z. Yang
1

votes
1

answer
14

Views

Move file change from one commit to the working copy

Let's say I just made commit1 that had two changes: modified fileA.txt modified fileB.txt Then I realized I made a mistake - I wasn't ready to commit my fileB.txt changes! I want the fileB.txt modifications to be in my working copy, and I want to amend the previous commit1 to only have fileA.txt mod...
ZakTaccardi
1

votes
1

answer
44

Views

Create a hotfix branch or a feature branch in gitflow model

I'm using this model in my team: Today my project stats is following: The stable version is running in production using master branch We developed new functionalities that need to be tested before production, so we have a release branch be testing under SIT Environment. This new functionalities jus...
RonaldoLanhellas
1

votes
2

answer
25

Views

Push modifications from a downloaded git repo

A colleague started working in one of our git repositories by downloading the project from gitlab instead of doing a checkout. I want to commit/push his modifications, but it's problematic and I'm not sure what the best course of action is (I'm not a git expert either). git status shows every file a...
dargaud
1

votes
1

answer
30

Views

Git clone doesn't download all the files due to windows limit on length of file path

I am trying to clone a Git repo on windows 7. But git is not cloning all the files. I have checked the repo and there are no submodules so adding --recursive flag is also not helpful. IMO the reason for above mentioned behavior is windows limit on file path upto 255 characters. Is there a way to res...
Yug Singh
1

votes
1

answer
31

Views

How to retain pre-rename history while moving few files from one GIT repository to another?

Summary of question I need to move few files from one repository to another, while keeping their history of changes. I already moved them in a source repository into a dedicated folder with git mv (per Greg Bauer's widely quoted post, which results in all pre-folder-move history not copied into the...
wass rubleff
1

votes
2

answer
48

Views

Git: How to squash all commits on `master` branch? [duplicate]

This question already has an answer here: How to squash all git commits into one? 14 answers I'm looking for a way to squash all git commits into a single big commit in master branch. I fully understand the consequences of what I'm trying to do, no need to explain that this is dangerous or that it'...
milosmns
1

votes
1

answer
51

Views

Git: How to checkout all deleted files through whole history

I want to restore all deleted files through whole history, which means to checkout files to the commit before the commit that delete it?
bilabila
1

votes
3

answer
53

Views

git workflow: should I commit before I pull?

I read the following post: How do you git fetch then merge? 'Error: Your local changes to the following files would be overwritten by merge' I work with my friend on the same branch with git. When he did changes to our project and he pulls the project, he gets the error, that his local changes will...
David
1

votes
3

answer
55

Views

Change current branch and keep local changes

I'm on branch a. I want to make a commit on branch b, so that someone who clones branch b has the same working directory as I have now. Stashing the current changes does not work because in some cases this results in a conflict. I'm looking for the equivalent of making a temporary copy of the workin...
Toast
1

votes
1

answer
44

Views

Github pull request shows wrong diff

I am having two branches: - master and - develop. I am trying to merge branch develop into master branch. I have checked with Tower and Araxis merge, those two branches are identical. But when I do a pull request on Github, I am seeing that there are 381 files changed, like files are not on master a...
be-codified
1

votes
2

answer
34

Views

How do I catch a git branch up to master when it is both ahead and behind?

I've created a branch called shift-development from master and did some work in the branch, putting it ahead of master by 40+ commits. I also made a small change to master, putting shift-development behind master by 1 commit. How do I catch shift-development up to master? i.e. bring the changes from...
NickBourque
1

votes
2

answer
31

Views

Merge a specific file from different branch/directory

I have two GIT branches: A with Pluto/test.txt B with Pippo/test.txt I want to merge only the file (test.txt) in the branch B into A. I tried to use: git checkout A git checkout B Pippo/test.txt but this creates a folder with the file in it like: A with Pluto/test.txt and Pippo/test.txt. However I w...
1

votes
3

answer
197

Views

git stash to save current changed file

I made a couple of changes in branch A. For some reason I have to stop developing this feature in branch A. I have another task for which I need to create a new branch. I know that by doing git stash and pop, I can save the current changes and restore it later while I can do whatever I want in the n...
Mellisa Lee
1

votes
3

answer
98

Views

error: The branch 'upgrading' is not fully merged

I recently cloned my application from Bitbucket and checkout to a new upgrading branch where I upgraded my application from rails 5.0.0.1 to rails 5.1.6: $ git checkout -b upgrading I firstly updated my Gemfile, the I ran bundle update: $ bundle update From the railsdiff website and from a new rails...
Asarluhi
1

votes
2

answer
31

Views

How to pull a remote branch locally?

I created a project on Gitlab and cloned it on my computer. So I only have one branch (master) locally (git branch only shows master). A colleague created a new branch. So now there are 2 branches on Gitlab but not on my computer. How do I do to have the branch created by my co-worker on my computer...
Nicryc
1

votes
2

answer
192

Views

If I run `git checkout -​- .` on branch. Is there any way I can get those files back?

If I have a load of uncommitted file changes and for whatever reason run git checkout -- on a file and then realise I need it back - is there any means of doing this? Have tried git checkout HEAD but I imagine HEAD is not where those files exist anymore?
cwalker
1

votes
2

answer
32

Views

Least stressful way to check a git repo's heads using the git CLI tool

What's the least stressful way to poke a git server for a listing of all the repo's head commits? More specifically, I'll be doing this a lot to a lot of git repos, so optimizing the query time is extremely important so as to not nuke the servers. This should be obvious, but: cloning is not an optio...
SoniEx2

View additional questions