Skip to content

Instantly share code, notes, and snippets.

View anandjagadeesh's full-sized avatar
😊
Changing the world, one line of code at a time!

Anand Jagadeesh anandjagadeesh

😊
Changing the world, one line of code at a time!
View GitHub Profile
@anandjagadeesh
anandjagadeesh / Setting Upstream of a Branch.md
Created July 2, 2020 19:33
Setting Upstream of a Branch

To set Upstream of a branch, you can use:

git branch --set-upstream-to origin <branch>

or using the short version

git branch -u origin 
@anandjagadeesh
anandjagadeesh / Diffs or files with conflicts.md
Created July 2, 2020 19:49
Showing diffs or files with conflicts during a merge or pull

You can view diffs or just filenames of files with conflicts during a pull or merge

To view diffs of files with conflicts, give:

git diff --diff-filter=U

Or if you have difftool set, for example yadt or vimdiff

@anandjagadeesh
anandjagadeesh / Change Author of Commit.md
Created July 2, 2020 19:51
Change Author For A Commit

To change the author of a commit, give

git -c user.name="<authorname>" -c user.email=<author_email> <commithash> --amend --reset-author

To delete any branch, you shouldn't be on that branch, so switch to another branch before giving the commands

To delete any branch run,

git branch --delete <branch_name>
or
git branch -d <branch_name>

But this fails if the branch hasn't been merged, so to force delete, if required, run,

@anandjagadeesh
anandjagadeesh / git config.md
Last active September 13, 2020 18:49
git config

How to configure name, email, etc in Git!

<...> means variable ---> Fill it with appropriate value and [...] means optional

To configure name for a repo: git config user.name "my name"

To configure name globally: git config --global user.name "my name"

To configure email for a repo: git config user.mail "myname@domain.com"