User Tools

Site Tools


git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
git [2025/12/06 16:10] – created reddygit [2026/05/02 20:13] (current) reddy
Line 1: Line 1:
 +
 +==== Git Remote Server ====
 +
 Setting up a git server is as easy as this... Setting up a git server is as easy as this...
  
Line 22: Line 25:
 git push origin main git push origin main
 </code> </code>
 +
 +==== Merge between branches ====
 +
 +<code>
 +# Get the current branch name
 +git branch  # The one with the asterisk is current
 +git branch --show-current
 +git rev-parse --abbrev-ref HEAD  # For old versions which dont have "git branch"
 +
 +# Merge from main to someBranch
 +git checkout someBranch
 +git merge main
 +
 +# Merge from someBranch to main
 +git checkout main
 +git merge someBranch
 +
 +# Set upstream branch for local branch
 +git push --set-upstream origin someBranch
 +</code>
 +
 +==== Sub Module ====
 +
 +A sub module creates a link to another Git repository.
 +
 +<code>
 +# Allow the use of file paths
 +git config --global protocol.file.allow always
 +
 +# Add the other repo as a submodule
 +git submodule add /Users/nitin/Documents/practice/try_git_child_1 child_1
 +
 +# Subsequently, fetch the changes from the submodule
 +git submodule update --remote
 +
 +# When someone wants to clone the parent repo
 +git -c protocol.file.allow=always clone --recurse-submodules /Volumes/path/to/repository
 +</code>
 +
 +==== Sub Tree ====
 +
 +A subtree is essentially a copy. The parent repository does not have any reference to the path of the child repository (therefore all the "git subtree" commands require the path to the child repository).
 +
 +<code>
 +# Add/Push/Pull
 +git subtree add/pull/push --prefix child_1 /Users/nitin/Documents/practice/try_git_child_1 main
 +</code>
 +
 +==== Git Checkout Subdirectory ====
 +
 +<code>
 +git clone --no-checkout --depth=1 --filter=tree:0 https://github.com/pockettheories/somerepo.git
 +cd test-git-partial-clone-big-small-no-bigtree
 +git sparse-checkout set --no-cone /subdir1 /subdir2 /subdir3
 +git checkout
 +</code>
 +
git.1765033804.txt.gz · Last modified: by reddy

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki