How to ensure that everything is clicked using git?

I like to delete repositions that I don’t work with from my computer. I’ll check something, I’m working on it, and when I’m done, I click everything and delete the folder from my computer. This way things stay neat, it's easy to get an overview of what I'm actually working on, and I know that I don't have local things waiting to be clicked.

But...

Before deleting my local repo, I want to make sure everything has been pressed on my remote. The process that I look through usually consists of three steps:

git st # check if there something I haven't committed git stash list # check if I've stashed something git log --oneline --decorate --all # check if all branches have been pushed 

I would like to simplify this. Especially the last step, which requires me to look at all my branches and see if the local and remote are synchronized. To be really sure, I’ll even have to scroll a bit to make sure that I haven’t missed anything.

I plan to write a script to do all this automatically, but maybe there is already a solution there? (As I understand it, I do not need to emphasize that I want this to be done on the command line and not use graphical interfaces: D)

How do you guys approach this? What is your process of verifying that you are not forgetting anything? What tools do you use? All ideas are welcome!

+6
source share
3 answers

To find out if the local and remote branches are synchronized, you need to compare the hashes of the HEAD versions.

When you run git branch -v -a you get a list of local and remote branches along with the hashes of the corresponding HEAD revisions:

 $ git branch -v -a develop 44e61b5 <Commit message> feature/CodeContracts c26edee <Commit message> * feature/Foo 3a40e22 <Commit message> master e68e28a <Commit message> remotes/origin/HEAD -> origin/master remotes/origin/develop 44e61b5 <Commit message> remotes/origin/feature/Bar be9666c <Commit message> remotes/origin/master e68e28a <Commit message> 

As you can easily see, development and development are relevant locally and remotely, feature/Bar does not exist locally, and feature/CodeContracts and feature/Foo do not exist remotely, so you should click them before deleting the local repository.

+5
source

Based on Daniel Hilgart's answer, I would recommend the following steps

Run git fetch --all to make sure you have the latest changes from all upstream repositories

Then run git branch -vva - (note double -v). This will print all branches ( a ), and for each branch, the last commit and branch information upstream (if an upstream is set).

The result will look like this:

  br1 88006cd Branch br2 0b68b6f [origin/br2] New commit c 9ed6569 Dummy * master f4664d4 [origin/master: ahead 1] my commit remotes/origin/HEAD -> origin/master remotes/origin/br3 9ed6569 Dummy remotes/origin/master 9ed6569 Dummy 

You can see that you have four local branches (master, c, br1, br2). master and br2 have upstream branches. br2 is fully pressed, the host has one local commit that is not yet pressed ("ahead 1").

br1 and c are local branches without upstream information. To do this, you must check and decide what to do - they can be completely combined and redundant; or you can push them upstream; or you may want to combine them locally, for example. to master, then click this. To see branches that are not fully merged with your local master, use git branch --no-merged master . In this example, this will print “br1 br2” (since branch c is the ancestor of the master).

Finally, you can see that for br2 the branch name for the / br 2 branch is specified, which does not exist. This means that the remote repository deleted this branch (and you selected this removal using "git remote prunes" or "git fetch -p"). Again, you have to decide whether you want to discard your local commits, or click or merge them again.

+3
source

Re-deleting your repos is a bad thing. For example, Linux - 126 MB; you can see how it can get old quickly. maybe this script would help. It checks all the folders in the directory (in this case /opt ) and gives the git status each of them.

 #!/bin/sh warn () { printf '\e[1;35m%s\e[m\n' "$*" } c () { printf '\ec' } compgen -d /opt/ | while read k do c cd $k git status warn $k read </dev/tty done 
+1
source

All Articles